AlgoFrames

Why is build-heap O(n)?

Warm-up · Multiple choice · about 3 min

Build-heap calls sift down on n / 2 nodes, and one sift down can cost O(log n). Yet the whole build runs in O(n). Pick the reason.

Learn the idea first: Building a heap in O(n), a visual lesson.

More Building a heap in O(n) problems