{[ promptMessage ]}

Bookmark it

{[ promptMessage ]}

Midterm_solution _2_

Midterm_solution _2_ - Midterm Exam-Solution Introduction...

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

Midterm Exam-Solution 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 Document
3. [10 points] A. Give the recurrences that describe both worst-case 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. Worst-case : T(n)=T(n-1)+ Θ (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 linear-time 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.

{[ snackBarMessage ]}

Page1 / 6

Midterm_solution _2_ - Midterm Exam-Solution Introduction...

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

View Full Document
Ask a homework question - tutors are online