HINTS FOR Homework 3 HINTS FOR Homework 3
Fundamental Algorithms, Fall 2001, Professor Yap

  1. In question 4(ii), there was a typo. The condition is "c1+c2 = 1" (not "c1 + c2 = n").
  2. In question 6(ii), there is a step that is not so easy to prove directly. We will give you the necessary additional information: let m be the length of the longest string in K. We can let U be the set of all ascii strings of length m, and assume that K\ib U. You may assume the existence of a hash function
    h* : U ® Zn2 = {0, 1, 2,..., n2-1 }
    such that h*(x) is different from h*(y) for all distinct elements x, y Î K. I.e., h* is perfect for K. This hash function is easy to compute and takes O(m) time.

    The idea is that you now store h*(k) instead of k into your data structure from part (i). You may assume that the binary number n2 can fit into an entry of your table. Now, describe how to modify the algorithm for Hash-Search(k) where k is any ascii string. You will need to some additional data structures to help you do this Hash-Search(k).

  3. For Question 6, the following facts are useful to know:

    (1) Markov's inequality: Suppose X is a random variable that is non-negative. Then, knowing the expected value E[X] of X, then you can get a bound on the probabality that X is greater than any value c > 0. It is actually, easiest to express c as a fraction of E[X]. Here is ``Markov's inequality'':
    Pr{X ³ c·E[X]} £  1

    c
    . For instance, Pr{X ³ 2·E[X]} £ 1/2. You should note that Markov's inequality only works if X is non-negative.

    (2) Geometric distribution (see p.1112): suppose X is number of times that we have to toss a coin before we obtain a head. Let the probability of getting a head be p in any single coin toss. Then E[X] = 1/p.

    For instance, if you have a (biased) coin which shows head with probability 1/5. Then you expect to toss the coin 5 times before you see a head. This seems an intuitive result.

  4. Question 1(ii). We can emulate the proof in the book that
    T = n
    å
    i=1 
    n
    å
    j=i+1 
    Xij
    where Xij=1 iff zi and zj were compared. In general, we can again use the estimate from the text, namely E[Xij] £ 2/(j-i+1) (note that this is now an upper bound, not the exact bound as it was before). But for j-i+1 £ k/3, we claim a better bound,
    E[Xij] = O(1/k).
    Here is the argument: consider the sets
    Lij = {zl: 0 < i-l £ k/3},       Rij = {zl: 0 < l-i £ k/3}.
    First assume that i > k/3 and j < n-k/3 so that |Lij|=|Rij|=\floork/3. Also, the set Zij as defined in the text has £ k/3 elements. Hence LijÈRijÈZij £ k. Note that the 3 sets are mutually disjoint. Consider the event ELij which is the probability that a pivot from Lij is picked before either zi or zj is picked. The event ERij is similarly defined using Rij. Note that
    Pr
    {Xij = 0} ³ Pr
    ( ELij ÇERij).
    But Pr(ELij) ³ 1 - 3/k and Pr(ERij) ³ 1 - 3/k. The two events are also independent, so
    Pr
    {Xij = 0} ³ (1-3/k)(1-3/k) > 1-6/k.
    Thus
    E[Xij] = Pr
    {Xij=1} < 6/k.




File translated from TEX by TTH, version 3.01.
On 23 Oct 2001, 08:43.