Concept Flow - Heap Extract Min or Max Bubble Down
Start: Extract root (min or max)
Replace root with last element
Remove last element from heap
Set current index = 0
Compare current with children
Left child smaller/larger?
Swap with smallest/largest child
Update current index to swapped child
Repeat until no swap needed
Done
This flow shows how extracting the root from a heap replaces it with the last element, then bubbles that element down by swapping with its smaller (min-heap) or larger (max-heap) child until heap property is restored.