Q:

parent of heap node

let k = index you are looking at

parent = (k - 1) // 2 # floor division

leftChild = 2 * k + 1

rightChild = 2 * k + 2
0

New to Communities?

Join the community