Tracing an Array Heap
ArrayHeap stores a binary min-heap in an array, in level order, with the root at index 0. A smaller value has higher priority. add places the new element at the end of the array and swims it up. remove moves the last element into the root and sinks it down.
Solution
add 60 [60]
add 90 [60, 90] no swap
add 40 [40, 90, 60] 40 swaps with 60
add 70 [40, 70, 60, 90] 70 swaps with 90
add 20 [20, 40, 60, 90, 70] 20 swaps with 70, then with 40
remove [40, 70, 60, 90] 70 moves to the root, swaps with 40
add 50 [40, 50, 60, 90, 70] 50 swaps with 70