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
Swap with smaller/larger child
Update current index to child's index
Repeat until heap property restored
Done
Extract the root element, replace it with the last element, then bubble down by swapping with the smaller (min-heap) or larger (max-heap) child until heap property is restored.