Solutions to CS 600 Test I
October 9, 2002
1. Find the big-oh relationships for the following functions.
Give your calculations. [20]
, , , , .
Solutions
Guess the order as
,
where means "is little oh of".
Let us now try to check the guess.
(a)
=
=
=
=
Hence
.
(b)
=
= .
Hence
.
(c)
=
=
Hence
.
(d)
=
=
=
= .
Hence
.
2. Let be an array of size , let denote the -th key of ,
let be the key being searched for in , and let be the probability
for .
Suppose that is always found in with the following probability:
for
for
where 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 and .
Do not compute. [6]
(b) Compute the average time from (a). You do not have to compute the value of yet. [7]
(c) Determine the value of constant in terms of and express the average
time in terms of only. What is the asymptotic average time ? [7]
You may use the following formulas if you need them:
,
,
,
.
Solutions
(a)
(b)
=
=
= .
(c) Since
= ,
=
Computing the left hand side, we get which is equal to .
Hence .
Substituting this into the equation of (b), we get for the average time which is
.
3. Answer whether or not the following statements are true.
You DO NOT need to give your reasons. [20]
(a) An NP-complete problem can be solved in time
for some constant in the worst case, where is the problem size and
is a polynomial in .
(b) If a problem is in class , then it can be solved by back tracking
a polynomial number of times in the worst case.
(c) If
, then
.
(d) If a problem is in class NP, then it can not be solved in polynomial time
in the worst case.
(e) Some problems in class NP need time to solve in the worst case.
Solutions
(a) True.
All the others are false.
4. A vertex cover of a graph is a subset of its vertex set such that every edge
of the graph is incident to at least one of the vertices in the subset.
The vertex cover problem asks whether or not a vertex cover of size exists
for a given graph.
Prove that the vertex cover problem is NP-complete. [20]
You may assume the followings:
(a) The vertex cover problem is in class NP.
(b) Graph Color, Bin Packing, Clique, 3SAT and Partition are NP-complete.
Solution: See the textbook.
5. The problem given below is called "Job Scheduling with Penalties".
Prove that it is in class NP. [20]
There are jobs
to be executed one at a time.
We are given execution times
, deadline dates
and penalties for missing the deadlines
. Assume that these numbers are all positive integers.
The problem is to find a schedule (i.e. sequence) of jobs so that the
total penalty is less than or equal to a given positive integer .
Solution:
For a certificate we can use a sequence of jobs. It is certainly of length
polynomial in the size of the problem.
The following algorithm is a verification algorithm.
It is assumed that the jobs are renumbered so that the first job is , the second
is etc.
; ;
for (
) {
;
if then
}
if , then return "no"
else return "yes".
Since the for loop takes at most iterations, this verification algorithm
is of polynomial time (). If you want to check whether or not all jobs
are accounted for, it can easily be done by modifying this algorithm. It would still
be .
Hence the Job Scheduling with Penalties problem is in class NP.