MidTrmFl05-key

MidTrmFl05-key - CSE 4081/5211 Pts 50 Algorithms Mid-Term...

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

View Full Document Right Arrow Icon
CSE 4081/5211 Algorithms Mid-Term Fall 2005 Time 70 min Pts 50 Print your name, and Grad/Undergrad status 1a. Solve the following recurrence equation (2 equations for GRAD students 1a and b)for general solution, by setting up a characteristic equation. [UG 10/ Grad 5] T n = 4T n-2 [Note: it is not T n-1 on the right hand side.] Ans: Characteristic equation: x 2 –4=0, Solutions, x=2, -2 T(n) = c.(2) n + d.(-2) n , for two constants c and d T(n) = Theta(2 n ) 1b GRAD : T n = 2T n-1 +1 [You have to homogenize first.] [Grad 5] Ans: Characteristic equation: x 2 –3x +2=0, Solutions, x=1, 2 T(n) = c.(1) n + d.(2) n , for two constants c and d T(n) = Theta(2 n ) 2a. Binary search algorithm looks into the middle element of the input array and depending on whether that element is less than the key or not the algorithm recursively calls itself on the left half or right half. Recursion terminates on single element input. Write a Ternary Search Algorithm that divides the input array into three equal portions (for the sake of convenience presume the input size to be 3^k for an integer k>=1) and recursively calls itself on one of the three portions after comparing the key with the two middle elements between the three portions (instead of the central middle element as in
Background image of page 1

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

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 4

MidTrmFl05-key - CSE 4081/5211 Pts 50 Algorithms Mid-Term...

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

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