University of Delaware Computer and Information Sciences CIS621 Algorithm Design and Analysis

Homework Set #1 Due September 21, 1995

1. Problem 4-4, parts a, b, and e.

2. Problem 7-1.

3. Problem 8-3, parts a and b. You may assume that n is a power of 3.

4. Problem 8-5, parts b and c.

You may use the following solution to part a:

Pr(x = A′[i]) = 6(i − 1)(n − i)/(n(n − 1)(n − 2)).

Proof: A′[i] is the median of three iff the three elements are A′[j], A′[i], and A′[k], where j < i < k. There are (i − 1)(n − i) triples whose median is A′[i], because there are i − 1

possible values for j and n−i values for k. Overall, there are ( \begin{matrix}n \\ 3 \end{matrix} ) triples, so the probability

is (i − 1)(n − i)/ ( \begin{matrix}n \\ 3 \end{matrix} ), which is the given expression.

The authors suggest using an integral in part c. I don’t feel it is necessary.