We were unable to load Disqus. If you are a moderator please see our troubleshooting guide.

Javohir • 3 years ago

There is typo in array -> binary tree calculation. Should be:


parent(i) = Math.ceil(i / 2 - 1)
leftChild(i) = 2 * i + 1
rightChild(i) = 2 * i + 2