hw03_sol - CS202HomeworkSolutions Question1 Array...

Info iconThis preview shows pages 1–5. Sign up to view the full content.

View Full Document Right Arrow Icon
CS202 Homework Solutions Question 1 Tree representation Original A r r a y 583419726 Array 5 8 3 1 4 7 9 After heapRebuild(a,3,9) 5 8 3 6 1972 4 2 6 5 8 3 1 6 7 9 2 4 After heapRebuild(a,2,9) 5 8 9 61 3 724 5 8 9 1 6 7 3 After heapRebuild(a,1,9) 5 8 9613724 2 4 5 8 9 1 6 7 3 2 4
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
After heapRebuild(a,0,9) 9 8 7 613 5 24 9 8 7 1 6 5 3 2 4 Sorted Swap first[0] with l a s t [ 8 ] 48761352 9 4 8 7 1 6 5 3 Sorted After heapRebuild(a,0,8) 86 7 4 1352 9 2 9 8 6 7 1 4 5 3 2 Sorted Swap first[0] with l a s t [ 7 ] 2674135 89 9 2 6 7 1 4 5 3 9 8
Background image of page 2
Sorted After heapRebuild(a,0,7) 7 6 5 413 2 89 7 6 5 1 4 2 3 9 8 Sorted Swap first[0] with l a s t [ 6 ] 265413 789 2 6 5 1 4 3 Sorted After heapRebuild(a,0,6) 64 5 2 13 9 8 7 6 4 5 Sorted S fi t[0] ith lt [ 5 3 4 5 2 1 1 2 3 9 8 7 Swap first[0] with last[5] 6 7 8 9 3 4 5 1 2 9 8 7 6 Sorted After heapRebuild(a,0,5) 5 4 3 21 6789 5 4 3 1 2 9 8 7 6
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Sorted Swap first[0] with l a s t [ 4 ] 1432 56789 1 4 3 2 9 8 7 6 5 Sorted After heapRebuild(a,0,4) 42 3 1 4 2 3 1 Sorted Swap first[0] with l a s t [ 3 ] 123 456789 9 8 7 6 5 1 2 3 Sorted After heapRebuild(a,0,3) 3 2 1 9 8 7 6 5 4 3 Sorted 2 1 9 8 7 6
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 11

hw03_sol - CS202HomeworkSolutions Question1 Array...

This preview shows document pages 1 - 5. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online