Start here · Essential guide
How the Heapsort Algorithm Works
Heapsort builds a max-heap, then repeatedly moves the largest value to the end. Learn each step, a worked example, Python code, and its O(n log n) speed.
Algorithms
How heapsort uses a heap to sort, how it differs from heapify and what heap operations cost.
Start here · Essential guide
Heapsort builds a max-heap, then repeatedly moves the largest value to the end. Learn each step, a worked example, Python code, and its O(n log n) speed.
No. Heapify fixes one node's place in a heap, while heapsort calls it repeatedly to build the heap and then to pull out values in sorted order.
Five sorting algorithms that most intro courses cover: bubble, insertion, merge, quick and heap sort. See how each works, how fast it runs, and its tradeoffs.
A heap is a tree-based data structure where parents are ordered against their children. Learn max-heaps, min-heaps, array storage, and priority-queue uses.
A binary heap's peek is O(1), insert and removing the root are O(log n), building from n items is O(n), and searching is O(n). Here is why each holds.
Related topics