Step 1 of 5 · Reading · ~1 min
Read
Operations
Pop (Sift-Down)
Remove the min (root): replace with the last element, shrink, then sift down.
python
At each level, find the smaller of left/right child. If it's smaller than the current, swap and recurse. Bounded by tree height: O(log n).
Symmetric to sift-up, but we go down. Together with push, gives complete priority queue API.
Up nextHeapify in O(n)Variants
Discussion
Ask a question, share an insight, or help someone who’s stuck.
Sign in to post a comment or reply.
Loading…