showHeap pseudocode - PowerPoint PPT Presentation

About This Presentation
Title:

showHeap pseudocode

Description:

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) ... – PowerPoint PPT presentation

Number of Views:43
Avg rating:3.0/5.0
Slides: 6
Provided by: steve545
Learn more at: https://www.d.umn.edu
Category:

less

Transcript and Presenter's Notes

Title: showHeap pseudocode


1
showHeap() 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)
2
heaptest2
i 1 i 2 i 3 i 4 i 5 i 6 ... i 16 i 17 i 18 i 19 i
20 d e ...
3
Upright Tree of heaptest2
1
2 3 4
5 6
7 8 9 10 11 12
13 14 15 16 17 18 19 20
4
Recursive 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
5
90 Rotated Tree of showHeap()
15 7
14 3 13 6
12 1 11
5 10
20 2 19
9 18
4 17 8
16
Write a Comment
User Comments (0)
About PowerShow.com