# hw03_sol - Question1 Array Treerepresentation 583419726...

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

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

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

View Full Document
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
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

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

View Full Document
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
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 11

hw03_sol - Question1 Array Treerepresentation 583419726...

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

View Full Document
Ask a homework question - tutors are online