1. Suppose that in a binary search, the key x being searched for in an array of length nfalls on a location n/2 or lower 9 times more often than on or higher than n/2.
a) Find the probability that x falls on a specific location in the upper half of the array. [10]
b) Formulate an equation for computing the tight upper bound of the average time
of the binary search for this case. [20]
c) Compute the tight upper bound of b),
that is, express the average time using big oh and show that it is tight. [10]
You may use the following equalities:
,
,
,
.
2. The following problem is called a partition problem:
Given a set S of objects {
a1, a2, ..., an}, and their size
s(a1), s(a2),
...,
s(an). Is there a subset T of S
such that
?
a) Give a definition of class NP. [10]
b) Prove that the partition problem is in class NP. [20]
3. The following problem is called a bin packing problem:
Given a finite set U of objects, a size
for each element u of
U, and k bins each with capacity 1.
Is it possible to pack the objects of U into the k bins ?
a) Give a definition of (polynomial) reduction. [10]
b) Prove that the partition problem can be reduced to the bin packing problem
in polynomial time. [20]