The Stack Overflow podcast is back! Listen to an interview with our new CEO.

New answers tagged


Yes, it would be Just the Level Order Traversal of the tree, In this case, it is 20,18,13,15,11,12,16,10,9,11,13,2,9,10,1. More generally for a generalized d-heap, the items may be viewed as the nodes in a complete d-ary tree, listed in breadth-first traversal order: the item at position $0$ of the array (using zero-based numbering) forms the root of the ...


The contents of the heap look like this: 04687, 046872, 042876, 024876. I have prefixed a 0 because, as you mention, the heap contents actually start in the second position.


For any element at index $i$ store its left chid at index $2i +1$ and right child at index $2i+2$. Your heap in the form of array without any insertion. The $0$ in the array given below means no key at that index. $$\fbox{4}\fbox{6} \fbox{8} \fbox{7}\fbox{0}\fbox{0} \fbox{0} \fbox{0}$$ After inserting $2$. $$\fbox{4}\fbox{6} \fbox{8} \fbox{7}\fbox{2}\...

Top 50 recent answers are included