Homework 10

# Homework 10 - Page 667#1-9 11-12 19-20 Page 692#7a 10a 16 17 Page 732#1-3 10a 15 Page 754#1 2 4 Page 789#3 4 8b 8c/p667#1 Please refer to this

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

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

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: /* Page 667 #1-9, 11-12, 19-20 Page 692 #7a, 10a, 16, 17 Page 732 #1-3, 10a, 15 Page 754 #1, 2, 4 Page 789 #3, 4, 8b, 8c */ //p667 #1 Please refer to this web-page for the better figure: http://dunes.ccsf.edu/~jahn4/cs111c/hw10.py?no=667-1 a: array() mergeSort(a,0,7) | |--- mergeSort(a,0,3) | |---mergeSort(a,0,1) | | |---mergeSort(a,0,0) | | |---mergeSort(a,1,1) | |---mergeSort(a,2,3) | |---mergeSort(a,2,2) | |---mergeSort(a,3,3) | |---mergeSort(a,4,7) |---mergeSort(a,4,5) | |---mergeSort(a,4,4) | |---mergeSort(a,5,5) |---mergeSort(a,6,7) |---mergeSort(a,6,6) |---mergeSort(a,7,7) //#2 n=21 h=log(n+1) = log(22) = 4.46 >> Height : 5 >> This is not a full tree. //#3 binary tree that has three levels. //a. max number of nodes in this tree. when the tree is a full tree, max number of nodes = 2^h -1 =2^3-1 = 7 //b. max number of leaves in this tree. when the tree is a full tree, max number of leaves = 2^(h-1) =2^2 = 4 //c. h = 10 max number of nodes = 2^h -1 =2^10-1 = 1023 max number of leaves = 2^(h-1) =2^9 = 512 //#4. recursive algorithm that counts the nodes in a binary tree....
View Full Document

## This note was uploaded on 01/23/2012 for the course CS 111C taught by Professor Metzler during the Spring '11 term at City College of San Francisco.

### Page1 / 7

Homework 10 - Page 667#1-9 11-12 19-20 Page 692#7a 10a 16 17 Page 732#1-3 10a 15 Page 754#1 2 4 Page 789#3 4 8b 8c/p667#1 Please refer to this

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

View Full Document
Ask a homework question - tutors are online