Hi there,
Is it possible to traverse a min heap to get a sorted list? Using pre/post/in traversal.?
Just need to clear some concept issues.
Printable View
Hi there,
Is it possible to traverse a min heap to get a sorted list? Using pre/post/in traversal.?
Just need to clear some concept issues.
Traversing through a heap has little meaning in terms of sorted order (either min heap or max heap). You must remove the top item from the heap and re-validate the heap to get the items back into a sorted order.
Traversing through a binary search tree using "in-order" traversal (left, node, right) will give you the sorted order of the items.