You are on page 1of 2

Advanced Algorithms 2011.

Exercises 12-13

Exercise 12.
The well-known Quicksort algorithm sorts a sequence of n numbers using
O(n log n) expected time with a small hidden constant factor, but it may
need O(n2 ) time in the worst case. Suppose that the latter property is
unacceptable for some specific application. We want to be on the safe side
and have our sequence sorted after O(n log n) time come what may, yet
almost preserve the speed of Quicksort as well. Good news is that this is
possible: We can take another sorting algorithm with O(n log n) worst-case
time and combine it with Quicksort in a certain way.
However, we consider this matter in a more general framework. Suppose
that we have two algorithms for some problem: a randomized algorithm
that runs in f (n) expected time, and a deterministic algorithm that runs in
g(n) worst-case time, where f (n) < g(n) for all n. (Note that we have not
used O()-notation here!)

Combine them to a new randomized algorithm that runs in s f (n) expected


time and O(g(n)) worst-case time, where s > 1 is some slowdown parameter
that the user can freely chose. The hidden factor in O(g(n)) may depend
on s and is not specified here. Make sure that you prove the claimed time
bounds for your construction.

See reverse page!

1
Exercise 13.
We are given a palette of k colors and a set of n elements. In the following,
a coloring is any function that assigns some color to each element. (This
should not be confused with graph coloring.)

13.1. Prove that there exists a family F of O(kek log n) colorings such that,
for every subset S of k elements, there exists some coloring in F that assigns
all k colors to S.

Hint: Use the Probabilistic Method and collect independent random color-
ings. Do the necessary calculations to show that the success probability is
positive.

13.2. Discuss: Can such a family F be used to efficiently detect a path of k


nodes in a given graph? Why, or why not?

13.3. Discuss: Can such a family F be used as a hashing scheme (to store k
out of n elements in a hash table, where each color corresponds to a memory
cell)? Why, or why not?

You might also like