Midterm ExamSolution
Introduction to Algorithms, spring 2009
1.
[10 points]Use a recursion tree to determine an asymptotically tight bound to the
recurrence T(n) = T(n/3) + T(2n/3) + O(n). Use the substitution method to verify
your answer.
2.
[15 points] Solve the following recurrences by giving tight
Θ
notation bounds.
You need to justify your answers.
(a)
T (n)=3T (n/5)+lg
2
n
(b)
T (n)=2T (n/3)+n lg n
(c)
T (n)=T (n/5)+lg
2
n
(d)
T (n)=8T (n/2)+n
3
(e)
T (n)=7T (n/2)+n
3
This preview has intentionally blurred sections. Sign up to view the full version.
View Full Document3.
[10 points]
A.
Give the recurrences that describe both worstcase and randomized
quicksort running time (you don’t need to obtain the running time).
B.
A smart NTHU professor claims that he has discovered an O (n) time
sorting algorithm (in the comparison model). Prove that he is wrong.
Solution:
A. Worstcase :
T(n)=T(n1)+
Θ
(n)
Randomized: T(n)=
B. The number of leaves of a decision tree which sorts n numbers is n!, and the
height of the tree is at least lg(n!), where nlgn
≤
lg(n!).
4.
[10 points] Professor Cecilia uses the following algorithm for merging
k
sorted lists,
each having
n/k
elements. She takes the first list and merges it with the second list
using a lineartime algorithm for merging two sorted lists, such as the merging
This is the end of the preview.
Sign up
to
access the rest of the document.
 Spring '09
 Naver
 Algorithms, Recursion, worstcase running time, redback tree

Click to edit the document details