CS 600 Test I



February 20, 2002



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



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



2. Let $L$ be an array of size $4n$, 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 for $x = L[i]$.
Suppose that $x$ is always found in $L$ with the following probability:



$p(i) = 2ci$ for $1 \leq i \leq n$
$= ci + cn $ for $n + 1 \leq i \leq 2n$
$= 3cn $ for $2n + 1 \leq i \leq 4n$



where $c$ is a constant.



(a) Formulate the equation for computing the average time of the Sequential Search with the probability distribution given above in terms of $c$ and $n$. Do not compute. [15]
(b) Guess the average time in terms of $n$. [5]
(c) Compute the average time from (a). You do not have to compute the value of $c$ yet. [20]
(d) Determine the value of constant $c$ in terms of $n$ and express the average time in terms of $n$ only. What is the asymptotic average time ? [15]



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. The length of a path in a graph is the number of edges in the path. The shortest path problem seeks to find a path of the shortest length between a give pair of vertices. Answer the following questions:



(a) Give a decision problem version of the shortest path problem. Let us call it the shortest path decision problem (SPDP). [5]
(b) Give two certificates for SPDP. [5]
(c) Prove that SPDP is in class NP. [10]





S. Toida
2002-02-20