You are on page 1of 7

CS 205 Quiz #6A Nov 8, 2012

NAME: __________________________________________________________________________

RUID:___________________________________________________________________________

Electronic Devices are not permitted during the quiz. These include but are not restricted to calculators,
computers and cell phones.
No communication between students or anyone outside of class is permitted during the quiz.
Textbooks, notes and any other written materials are not permitted during the quiz.

DO NOT OPEN UNTIL


INSTRUCTED TO DO SO

1. In each blank, write the letter of the formula that most closely provides the number of iterations
performed by the corresponding loop. Ignore any requirement to use a ceiling or floor function.
Note that an option may be used zero or more times (i.e. once, more than once, not at all).
A) a

B) x0

C) (x0 a)/k

D) (a - x0)/k

E) x0 + a k

F) (x0 a)/k

G) x0 / a

H) a / x0

I) x0 ^ a

J) a ^ x0

K) logk(x0 a)

L) logk(a - x0)

M) logk(a)

N) logk(x0)

O) logk(x0 / a)

P) logk(a / x0)

Q) logx0(a)

R) loga(x0)

S) logk(logx0(a))

T) logk(loga(x0))

U) logx0(a)/lg(a)

V) loga(x0)/logk(x0)

W) logx0(a)/logk(x0)

X)

____________ a)

x
x0
while x > a
x
x - k
end

where:
x0 and a are integers
a < x0 and k > 1

____________ b)

x
x0
while x < a
x
kx
end

where:
x0 and a are real numbers
0 < x0 < a and k > 1

____________ c)

x
x0
while x > a
x
x / k
end

where:
x0 and a are real numbers
0 < a < x0 and k > 1

____________ d)

x
x0
while x < a
x
xk
end

where:
x0 and a are real numbers
1 < a < x0 and k > 1

____________ e)

x
x0
while x > a
x
end

where:
x0 and a are real numbers
1 < a < x0 and k > 1

2. Find the least integer n such that f(x) is O(xn) for each of these functions. If no such n is
possible, write Impossible.

_____________ a) f(x) = 2x3 + x2 log x

_____________ b) f(x) = 4x3 + (log x)5

_____________ c) f(x) = (x4 + x2 + 1)/(x3 + 1)

_____________ d) f(x) = (x4 + 5log x)/(x4 + 1)

_____________ e) f(x) = x log x

_____________ f) f(x) = x(log x)3

_____________ g) f(x) = x(8x2 + 3x + 5log x)

_____________ h) f(x) =

_____________ i) f(x) = (0.5)x + 6x7

_____________ j) f(x) = 1/x + 1/(x!)

3. Recall that to establish a big-O relationship, we find C and k such that f( ) C g( )


for x > k. Assume C, k and x are real numbers. For each of the following blanks, write True if
the given C and k establish a big-O relationship. Otherwise, write False.
a) f(x) = x + 10,

f(x) = O(x)

_____________

C = 1, k = 1

_____________

C = 10, k = 1

_____________

C = 2, k = 6

_____________

C = 100, k = 1

b) f(x) = x2 + x,

f(x) = O(x2)

_____________

C = 2, k = 0

_____________

C = 2, k = 1

_____________

C = 2, k = 2

_____________

C = 0.5, k = 2

c) f(x) = 2x + 2x,

f(x) = O(2x)

_____________

C = 2, k = 0

_____________

C = 2, k = 1

_____________

C = 2, k = 2

_____________

C = 0.5, k = 2

d) f(x) = lg(x) + 4,
_____________

C = 3, k = 4

_____________

C = 4, k = 1

_____________

C = 2, k = 16

_____________

C = 1, k = 256

e) f(x) = x! + 2x,

f)

f(x) = O(lg(x))

f(x) = O(x!)

Assume x N for this problem only

_____________

C = 2, k = 2

_____________

C = 2, k = 3

_____________

C = 1, k = 4

_____________

C = 2, k = 4

f(x) = 7 + 1/x,

f(x) = O(1)

_____________

C = 7, k = 0

_____________

C = 7, k = 1

_____________

C = 8, k = 0

_____________

C = 8, k = 1

4. What is the effect in the time required to solve a problem when you increase the size of the input
from n to n+1, assuming that the number of milliseconds the algorithm uses to solve the
problem with input size n is each of the quantities expressed below? Let W1 denote the runtime
with input size n+1 and let W0 denote the runtime with input size n. In each blank, write the
corresponding letter from the table below. Note that an option may be used zero or more times
(i.e. once, more than once, not at all).
A) W1 - W0 = 0

B) W1 - W0 = 1

C) W1 - W0 = 2

D) W1 - W0 = n

E) W1 - W0 = 2n

F) W1 - W0 = 2n+1

G) W1 - W0 = n+1

H) W1 - W0 = lg(n)

I) W1 - W0 = lg(n+1)

J) W1 - W0 = lg(n+1) lg(n)

K) W1 / W0 = 2

L) W1 / W0 = 2n

M) W1 / W0 = n+1

N) W1 / W0 = 2n+1

O) W1 / W0 = 2n+2

P) W1 / W0 = lg(n)

Q) W1 / W0 = n2

R) W1 / W0 = n!

S) W1 / W0 = 2n

T) W1 / W0 = 2n+1

U) W1 / W0 = 2(2n+1)

___________ a) lg n

___________ b) n

___________ c) 2n

___________ d) n2

___________ e) 2n

___________ f) 2 ^ (n2)

___________ g) n!

Scratch Paper

You might also like