So a binary heap can be implemented as follows:
For any index i...
parent of i = floor(i/2)
left child of i = 2i
right child of i = 2i+1
But what about for non-binary heaps? Say, a 5-heap. What would the formula be then?
Printable View
So a binary heap can be implemented as follows:
For any index i...
parent of i = floor(i/2)
left child of i = 2i
right child of i = 2i+1
But what about for non-binary heaps? Say, a 5-heap. What would the formula be then?