CS 600 Test I
October 7, 1998



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:
$\Sigma_{i=1}^{n} 2^{i} = 2^{n+1} - 1$, $\Sigma_{i=1}^{n} i2^{i} = (n-1)2^{n+1} + 2$, $\Sigma_{i=1}^{n} i^{2} = (2n^{3} + 3n^{2} + n)/6$, $\Sigma_{i=1}^{n} 1/i \simeq \ln n$.



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 $\Sigma_{a_{i} \in T} s(a_{i}) = \Sigma_{a_{i} \not\in T} s(a_{i})$ ?



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 $s(u) \leq 1$ 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]


 

S. Toida
1999-08-30