1. Find the big-oh relationships for the following functions.
Give your calculations. [30]
n1/3, 3n,
(ln n)2,
5n/2, lnln 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, and let p(i)
be the probability
that x = L[i].
Assuming the following (1) - (3), answer the questions (a) and (b) below
for the binary search (see next page):
(1) x is always found
in L.
(2) The probability that x is found with 5 or less number of comparisons is 40%,
and all the other cases together occur 60% of the time. Also assume that each number of
comparisons is equally probable within each group.
(3) The number of keys n is given by n = 2k - 1
for some integer k.
Answer the following questions:
(a) Find the probability p(i) in terms of n. [15]
(b) Compute the average time (number of comaprisions) of the binary search algorithm
in terms of n. [35]
You may use the following formulas if you need them:
,
,
,
.
3. Find a certificate for each of the following problems: [20]
(a) Set Cover
(b) String Matching
Set Cover: Given a set X and a collection C of subsets of X, is there a subcollection
of C such that every element of X is in some member of the subcollection ?
String Matching: Given two strings S and T, is S a substring of T ?