Introduction to heapsort


Heapsort is another efficient sort algorithm that uses the heap data structure under the hood to sort a list. It can be considered an efficient implementation of selection sort using the heap data structure.

How is heapsort similar to selection sort?
Similar to selection sort, heapsort divides the input list into sorted and unsorted regions. It iteratively shrinks the unsorted region by extracting the largest element from it and inserting it into the sorted region. However, it performs this step more efficiently by using a heap data structure rather than a linear scan-link selection sort. 

Example

Liking the course? Check our discounted plans to continue learning.