Homework 2 Homework 2
Fundamental Algorithms, Fall 2001, Professor Yap

DUE: Mon Oct 8, in class

NOTICE:

  1. Understanding the function log(x) function is very important. Recall that ln(x) means log to the natural base e, and lg(x) is log to base 2.

    (a) Clearly, ln(x) goes infinity as x goes to infinity. But how can we prove this without calculus? In discrete math, the log function arises as the harmonic numbers Hn=1+ (1/2) + + (1/n). You should know that Hn = ln(n) +Theta(1) (see text). Thus, it is enough to show that Hn goes to infinity as n goes to infinity. Prove this.

    (b) But while ln(x) is unbounded, it is also a very slow growing function. For instance, Hn = O(nc) for any constant c > 0. Prove this in the case of c=1/2.

    HINTS: Please read Appendix A.2 for ideas for how to estimate sums. For part (a), we suggest that you assume n=2k for some k 2 and group the summation of Hn into k groups. For part (b), split the sum of Hn into two parts, the first part with about terms.

  2. Suppose we have two coins, one fair and one fake. The fair coin, has equal probability of showing head or tail. The fake coin is very biased: it always show head. Let C be a random coin, obtained by picking the fair or fake coin with equal probability. So, C is a random object with Pr{C=fair coin}=1/2. Note: you may refer to the Textbook, page 1105 for a simpler version of this problem. Let B be the event {C = biased coin}, and for any natural number n, let An be the event {n flips of C yields head every time }.

    (a) Compute the probability Pr(B|An).

    (b) What is the minimum number n of flips needed to determine whether C is fair or fake with 99% certainty? We want a numerical value for n, but show the working (probably using a hand calculator).

  3. What is the probability space in the analysis of Quicksort? That is, you must describe a finite set S and tell us for each w S, tell us how to determine its probability Pr(w). Each w corresponds to a ``experiment'', or a complete run of the Quicksort algorithm. Illustrate the general describe with a special case n=4. What is |S| when n=4? Give upper and lower bounds on the size of |S|.
  4. Give another proof that Randomize-in-Place(A) is correct, using the formula in C.2-6 (p.1106)

    HINT: let σ = (x1,..., xn) be any permutation of [1..n]. Show that Ai be the event {A[i]=xi}. Prove that the probablity that the array A represents σ is 1/n!. Again, use the formula in C.2-6 (p.1106).

  5. Exercise 5.3-5, page 105 (see also p.101). This exercise is to prove that the probability that all elements in the array P are unique at the end of the Permute-by-Sorting algorithm is at least 1 (1/n). HINT: use the formula in C.2-6 (p.1106), which we briefly mentioned class. The binomial series and the series for ex = 1 + x + x2/2! + may be useful.

ADDITIONAL QUESTIONS (not graded, but we will sketch answers)

  1. Generalize the proof above to show that Hn = O(nc) for any c > 0.
  2. Exercise A.2-1 (p. 1067)
  3. Exercise A-1 (p. 1069)




File translated from TEX by TTH, version 3.01.
On 26 Sep 2001, 15:28.