This preview shows pages 1–2. Sign up to view the full content.
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: Solutions for CAS 702 Midterm 2007 Problem 1a Let k j and i j be the values of k and i respectively after statement i := i + i is executed j times. Then we observe that i = 2 , k = 1 and i j = 2 j +1 , k j = i 2 j 1 = 2 2 j . The loop ends when k j = 2 2 j ≥ n , or j ≥ lg n 2 . So j = d lg n 2 e = Θ(lg n ). Problem 1b The conjecture is false. A counter example is f ( n ) = 2 n and g ( n ) = n . Problem 1c Both are false. The curve f ( n ) keeps fluctuating and touching the curves of a Θ( n 2 ) and a Θ(1) function. Problem 1d We have 1 + α = α 2 since α is a root of x 2 x 1 = 0. We show that α i 2 ≤ F i ≤ α i 1 for i ≥ 2 by induction. It hold for i = 2 (base case). Assume the inequalities hold for any k smaller than i . Then, F i = F i 1 + F i 2 ≤ α i 2 + α i 3 = α i 3 ( α + 1) = α i 3 α 2 = α i 1 . Similarly we can prove that α i 2 ≤ F i . It follows immediately that F i = Θ( α i )....
View
Full
Document
This note was uploaded on 10/26/2009 for the course CAS 702 taught by Professor Zera during the Fall '09 term at McMaster University.
 Fall '09
 Zera

Click to edit the document details