DSA · Reimagined
Trees medium time O(log n) space O(1)

Heap — Extract Max

The maximum is always the root. To remove it, swap it with the last node, drop that last slot, then sift the new root down until the heap property holds again — about log n steps.

10584132

We start from a max-heap — the largest value is at the root.

1 / 16

Practice

Machine twin: /dsa-viz-v2/heap-pop.json — the full deterministic run as structured data.