CS 600 Test I



October 7, 2003



1. Find the big-oh relationships for the following functions. Give your calculations. [30]



$3^{n}$, $n \ln n$, $(\ln n)^{2}$, $5n \ln n + n^{2}$, $n !$.



2. 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$ by Sequential Search, and let $p(i)$ be the probability for $x = L[i]$.
Suppose that $x$ is always found in $L$ with the following probability:



$p(i) = ci$ for $1 \leq i \leq n/2$
$= cn/2 - ci $ for $n/2 \leq i \leq n$



where $c$ is a constant.



(a) Formulate the equation for computing the average number of comparisons of the Sequential Search with the probability distribution given above in terms of $c$ and $n$. Do not compute. [5]
(b) Estimate the average number of comparisons made without any calculations. Justify your answer. [10]
(c) Compute the average time from (a). You do not have to compute the value of $c$ yet. [13]
(d) Determine the value of constant $c$ in terms of $n$ and express the average number of comparisons in terms of $n$ only. [12]



You may use the following formulas if you need them:



$\Sigma_{i=1}^{n} i2^{i} = (n - 1) 2^{n + 1} + 2$, $\Sigma_{i=1}^{n} i^{2} = n( n + 1 )(2n + 1)/6$,
$\Sigma_{i=1}^{n} i^{3} = ( n( n + 1 )/2 )^{2}$, $\lg (n!) = \Theta(n\lg n)$.



3. A set cover of size $k$ of a set S is a collection of $k$ subsets of S such that every element of the set S is included in at least one of the subsets of the collection.
The set cover problem asks whether or not a set cover of size $k$ exists in a given collection of subsets of a given set.



(a) Give a certificate for the set cover problem. [10]
(b) Give an outline of your verification algorithm for the certificate of (a). [10]
(c) Is the set cover problem isn class NP ? Justify your answer. [10]





S. Toida
2003-10-09