First page Back Continue Last page Graphics
Heapsort
Yet another method for sorting…
- Assuming data is stored in an array.
- Data is unsorted.
The data can be sorted efficiently O(n log(n)) by performing the following steps:
- Rebuild the order of the elements in the array to be a heap. (Time to do this is O(n log(n))
- Extract highest items from the array while continuously rebuilding the heap portion after each extraction. (Time to do this is also O(n log(n))