Midterm2_sol - Solutions to Midterm 2 Question 1 20 20(a...

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

View Full Document Right Arrow Icon
Solutions to Midterm 2 Question 1 (a) C (20 , 2) + C (20 , 3) = 20! 2!18! + 20! 3!17! (b) C (20 + 2 - 1 , 2) + C (20 + 3 - 1 , 3) = 21! 2!19! + 22! 3!19! (c) ( C (21 , 2) + C (22 , 3)) 5 = ( 21! 2!19! + 22! 3!19! ) 5 Question 2 (a) mean has n + 1 operations, foo has 3 operations, sum=sum+foo has 1 operation and sqrt(sum) has 1 operation. Considering the loop, we know that the number of operations is n (( n + 1) + 3 + 1) + 1 = n 2 + 5 n + 1 . (b) Best=Worst= O ( n 2 ) (c) Move the line u := mean ( a 1 ,...,a n ) outside the main for loop. The new running time is ( n + 1) + 4 n + 1 = 5 n + 2 O ( n ) . Question 3 Basis Step: n = 1 . LHS = 2 3 = 1 - 1 3 = RHS Inductive Step: Assume 2 3 + 2 9 + ··· + 2 3 k = 1 - 1 3 k Then 2 3 + 2 9 + ··· + 2 3 k + 2 3 k +1 = 1 - 1 3 k + 2 3 k +1 = 1 - 1 3 k +1 Question 4 (a) By pigeonhole, 13+1 = 14 cards must be dealt, so 3 players must be dealt. 1
Background image of page 1

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

View Full DocumentRight Arrow Icon
(b) By pigeonhole, we need 3 · 13 + 1 = 40 cards. Thus 8 players must be dealt. Question 5
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 06/07/2011 for the course COT 3100 taught by Professor Staff during the Summer '08 term at University of Florida.

Page1 / 3

Midterm2_sol - Solutions to Midterm 2 Question 1 20 20(a...

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

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