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: CAS 702 – Data Structures and Algorithms Midterm Exam 30 points, 4 problems, 2 pages October 11, 2007 Justify your answers Name: Student number: Signature: Problem 1 a. Find a theta notation, i.e. Θ( ... ), for the number of times the statements i = i + i is executed. 2p i = 2 k = 1 while ( k < n ) k := i × i i := i + i b. Let f ( n ) and g ( n ) be asymptotically positive functions. Prove or disprove the follow ing conjecture: f ( n ) = O ( g ( n )) implies 2 f ( n ) = O (2 g ( n ) ). 2p c. For f ( n ) = 1 + ( n sin( nπ 2 )) 2 , and g ( n ) = 3 n , determine whether f ( n ) = O ( g ( n )) and whether g ( n ) = O ( f ( n )). 2p d. Fibonacci numbers are defined by the recurrence: F 1 = F 2 = 1, and F i +2 = F i +1 + F i . Prove that F i = Θ( α i ) where α = 1+ √ 5 2 is the positive root of x 2 x 1 = 0. (Hint: you may prove by induction that α i 2 ≤ F i ≤ α i 1 for i ≥ 2) 2p Problem 2 a. Give the best and worst running time for Heap sort and Quick sort using theta nota...
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