Heapsort
The heapsort is a sorting algorithm using max-heap data structure. It basically works like this:
- Divides the input into a sorted and an unsorted region.
- Takes the largest element from the unsorted region and inserts it into the sorted region.
- The unsorted region is kept as a heap, which allows finding the largest element quickly.
Complexity
- Worst-case:
Resources
- Heapsort visualization – David Galles
- Heapsort in 4 minutes – Youtube