Content deleted Content added
mNo edit summary |
Notheruser (talk | contribs) m fmt links |
||
Line 22:
If you regard the array as a screwed-up heap, you can fix it in [[Big O|O]](''n'') time by restoring the heap property from the bottom up. Consider each trio containing a node and its two children, starting from the end of the array; if the greatest value of the three nodes is not in the top node, exchange it with the top node. This puts the former top node at the top of a subtree which may contain nodes greater than it is; so we must compare it with its new children and possibly repeat the process.
==External
* http://mathworld.wolfram.com/Heap.html
|