Homework 1

Due Date: Sep 21, 2009

Readings: CLRS Chapter 3 & HO #A2, A4

1. Do CLRS Problem 3-2.

2. Do CLRS Problem 3-3a for the following functions only:

(√2)lg n     n2         n!
(lg n)!     lg2 n      lg n!
22n         ln ln n     n 2n
(n+1)!     √lg n       2n

3. All functions described below are assumed to be eventually positive and defined on virtually all of the natural numbers.

  1. Give two functions f, g such that f is neither O(g) nor Ω(g).
  2. Give a function f that satisfies both conditions: f is Ω(na) for any constant a, and f is O(bn) for any constant b > 1.

4. This exercise concerns the algorithm on page 4 of Handout #A4. Answer the following questions.

  1. Let P(i) be the worst-case running time of perm(i). Write a recurrence for P(i).
  2. Give a closed-form formula for P(2). Show your work.
  3. Let T(n) be the worst-case running time of main. Give a tight estimate of T(n). Justify you answer.
  4. Modify the algorithm so that the worst-case running time of main is Θ((n-1)!). Justify you answer.