AlgoScope

Min Heap

A binary heap whose root is the smallest value.

Data structures, data structure, intermediate
The array is now a min heap. The root holds 1, the smallest value.9481726
The array is now a min heap. The root holds 1, the smallest value.9481726

Binary Heap: Build a min heap

Result, step 12 of 12

A min heap, in 8 comparisons and 4 swaps. Building costs O(n), not O(n log n).

Cost

Insert
O(log n)
Extract min
O(log n)
Peek
O(1)
Space
O(n)

A variant of

Taught by the same lesson

Binary Heap covers these too, in the same run.