AI engineering glossary · Data structures algorithms
What is heap sort?
Heap sort: A sorting method that builds a max-heap from the data and repeatedly removes the largest item to fill the result from the end. It runs in O(n log n) in every case and in place, but is not stable.
Heap sort: an example
Build a max-heap from [4, 10, 3, 5], swap the top 10 to the end, restore the heap, and repeat until sorted.
Related terms
More Data structures algorithms terms
- Heapify
- Heuristic
- Huffman coding
- In-place algorithm
- Insertion sort
- Interval scheduling
- Kadane's algorithm
- Knapsack problem
Where you learn it
Heap sort is part of the AI Engineering Program, which teaches it with notes, a hands-on lab and an exam. The first lesson is free.