Discussion 10: Heaps Lecture note: http://homepages.math.uic.edu/~jan/mcs360/expression_trees.pdf 4 2 3 1 5 6 . 4 x . 4 2 x . 4 2 3 x . 4 2 3 1 x . 4 2 3 1 5 -> 4 5 3 1 2 -> 5 4 3 1 2 x . 5 4 3 1 2 6 -> 5 4 6 1 2 3 -> 6 4 5 1 2 3 Pop from this heap: -: 6 -> 3 4 5 1 2 -> heapify: -> 5 4 3 1 2 -: 6 5 -> 2 4 3 1 -> heapify: 4 2 3 1 -: 6 5 4 1 2 3 -> 3 2 1 -: 6 5 4 3 -> 1 2 -> 2 1 -: 6 5 4 3 2 -> 1 -: 6 5 4 3 2 1