Skip to content

Trees

Heaps

Members: Free account

Lessons on this topic

Intermediate · 30 minYou are hereRead

Binary heaps

A heap is a complete binary tree stored in an array, with every parent no larger than its children, so the smallest key sits in cell 0 and a priority queue costs O(log n) per operation.

Intermediate · 25 minYou are hereRead

Heapsort

Build a max-heap from the bottom up in O(n), then swap the root to the end and sift down, again and again, and the array is sorted in place in O(n log n).

Intermediate · 20 minYou are hereRead

d-ary heaps

Give each node d children and a heap has about log_d n levels, so pushes compare less while pops compare up to d children on every level.

Phasorium

Account

Sign inWith Google, GitHub or your email

Subjects

Site

Look