

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Priority Queues
incomplete
2: Priority Queue Code
incomplete
3: Heaps
incomplete
4: Why Use Heaps?
incomplete
5: Pop
incomplete
6: Priority Queue With a Heap
incomplete
This lesson's interactive features are locked, please to keep using them
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.
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]
Complete the pop method and its helper method, bubble_down.
Note: bubble_down does not return a value.