Title: showHeap pseudocode
1showHeap() pseudocode
typedef BinHeapInfo BinHeap void showHeap(BinH
eap subtreeRoot, Integer height) if
subtreeRoot exists showHeap(subtreeRoot-gtrightC
hild(), height 1) print 6 height
spaces print subtreeRoot-gtkey() showHeap(sub
treeRoot-gtleftChild(), height 1)
2heaptest2
i 1 i 2 i 3 i 4 i 5 i 6 ... i 16 i 17 i 18 i 19 i
20 d e ...
3Upright Tree of heaptest2
1
2 3 4
5 6
7 8 9 10 11 12
13 14 15 16 17 18 19 20
4Recursive Calls to showHeap()
showHeap(root, 0) // key 1 showHeap(right(root),
1) // key 3 showHeap(right(right(root)), 2) //
key 7 showHeap(right(right(right(root))), 3)
//key 15 showHeap(right(right(right(right(root
)))), 4) print key 15 in field of 3
6 showHeap(left(right(right(right(root)))),
4) print key 7 in field of 2
6 showHeap(left(right(right(root))), 3) // key
14 showHeap(right(left(right(right(root)))),
4) print key 14 in field of 3
6 showHeap(left(left(right(right(root)))),
4) print key 3 in field of 1
6 showHeap(left(right(root)), 2) // key 6
590 Rotated Tree of showHeap()
15 7
14 3 13 6
12 1 11
5 10
20 2 19
9 18
4 17 8
16