1. Let L be an array of size n, let L[i] denote
the i-th key of L,
let x be the key being searched for in L, and let p(i)
be the probability
that x = L[i].
Assuming the following (1) - (3), answer the questions (a) and (b) below
for the binary search (see next page):
(1) x is always found
in L.
(2) The probability that x is found with 5 or less number of comparisons is 40%,
and all the other cases together occur 60% of the time. Also assume that each number of
comparisons is equally probable within each group.
(3) The number of keys n is given by n = 2k - 1
for some integer k.
Answer the following questions:
(a) Find the probability p(i) in terms of n.
(b) Compute the average time (number of comaprisions) of the binary search algorithm
in terms of n.
2. Give a formal encoding of directed graphs as binary strings using
an adjacency list representation.
3. Suppose that a language L can accept any string
in polynomial time,
but that the algorithm that does this runs in superpolynomial time
if
.
Argue that L can be decided in polynomial time.
4. 34.2-1 on p. 982 of the textbook.
Due October 2, 2003 before the lecture time