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.

Level: intermediateTopic: Data structures algorithms

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

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.

Before you go

Take the cheat sheet with you

One free PDF: the key AI-engineering terms, formulas and Python idioms. No spam; unsubscribe any time.