We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

Pop

To complete our min heap, we need to be able to remove the minimum element. This is called a pop operation. It's a bit more complicated than push because we need to maintain the tree structure.

Min Heap Visualization

Again, for reference, here's a visualization of a min heap:

And here's the array representation:

[8, 10, 9, 21, 31, 27, 12, 58, 99, 42, 33, 39]

Assignment

Complete the pop method and its helper method, bubble_down.

Note: bubble_down does not return a value.