You are on page 1of 2

Department of Computer Science

University of Houston
COSC 3320 - Advanced Data Structures and Algorithms
Spring 2014, Homework 1, Due Feb. 5 at 11.30am.
Please turn in odd numbered questions as a separate booklet and even numbered one as a separate booklet. Make sure that booklets are stapled. Do
NOT turn in binders, folders, etc.
1. Draw the recursion tree for T (n) when n = 6 where T (n) = T (n/2) +
T (n 1) if n is even and T (n) = T (n 1) + T (n 2) if n is odd.
Assume T(1) = 1.
2. Solve the recursion: T (n) = T (n/2)+T (n/4)+O(n). You may assume
n is a power of 2 and that T (1) = (1).
log n

3. Compare the functions (log n)! and 22


and establish the best possible relationship between these two functions using one of the following:
O, , , o, .
4. Derive best possible upper and lower bounds for

Pn

i
i=1 2

/ (i).

5. The Master Theorem has 3 cases in Chapter 4 of text. Find a recurrence that is NOT in the text (not in chapter and not in the exercises
or problems) that falls in between Cases 1 and 2 and another that
falls in between Cases 2 and 3 so that both cannot be analyzed by the
Master Method.
6. Analyze the worst-case time complexity of the following algorithm in
detail: Input is an array of some size, say n, containing numbers. You
may assume n is a power of 4.
Algorithm Weird(Array A)
If A is of size 1 or 4, then call Merge-sort(A)
otherwise {
Divide A into three equal parts B, C, D and E.
Weird(B)
Weird(C)
Weird(D)
Weird(E)
E = Merge(B,C)
F = Merge(D,E)
1

A = Merge(E,F)
}
Output A

You might also like