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
- Is it a max-heap? Warm-up
- Heapify Standard
- Count sift steps Standard
- Sift down one index Standard
- Implement build-heap Challenge