Edit page

Heap Sort

Heapsort is a comparison-based sorting algorithm. Heapsort can be thought of as an improved selection sort: like selection sort, heapsort divides its input into a sorted and an unsorted region, and it iteratively shrinks the unsorted region by extracting the largest element from it and inserting it into the sorted region. Unlike selection sort, heapsort does not waste time with a linear-time scan of the unsorted region; rather, heap sort maintains the unsorted region in a heap data structure to more quickly find the largest element in each step. (Source: Wikipedia)

Algorithm Visualization

Algorithm Visualization

Complexity

NameBestAverageWorstMemoryStableComments
Heap sortn*log(n)n*log(n)n*log(n)1No

References

  • Geeksforgeeks
  • Wikipedia
  • YouTube
  • Programiz
  • Hackerearth