Sei sulla pagina 1di 7

CS 205 Quiz #6B 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) lg(x0 a)

B) lg(a - x0)

C) lg(a)

D) lg(x0)

E) lg(x0 / a)

F) lg(a / x0)

G) logx0(a)

H) loga(x0)

I) lg(logx0(a))

J) lg(loga(x0))

K) loga(x0)/lg(a)

L) a - x0

M) logx0(a)/lg(a)

N) logx0(a)/lg(x0)

O) x0 + a

P) x0 a

Q) -lg(logx0(a))

R) -lg(loga(x0))

S) x0 ^ a

T) a ^ x0

U) -logx0(a)/lg(a)

V) -logx0(a)/lg(a)

W) x0

X)

____________ a)

x
x0
while x > a
x
x - 1
end

where:
x0 and a are integers
a < x0

____________ b)

x
x0
while x < a
x
2x
end

where:
x0 and a are real numbers
0 < x0 < a

____________ c)

x
x0
while x < a
x
x / 2
end

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

____________ d)

x
x0
while x < a
x
x2
end

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

____________ e)

x
x0
while x > a
x
end

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

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) = 2x2 + x3 log x

_____________ b) f(x) = 3x5 + (log x)4

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

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

_____________ e) f(x) = x / log x

_____________ f) f(x) = x2(log x)8 + x2

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

_____________ h) f(x) =

_____________ i) f(x) =

_____________ j) f(x) = x5 (

+ 1/x)

3. Recall that to establish a big- relationship, we find C and k such that f(x) 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- relationship. Otherwise, write False.
a) f(x) = x + 0.5,

f(x) = (x)

_____________

C = 1, k = 1

_____________

C = 0.5, k = 1

_____________

C = 1.5, k = 3

_____________

C = 0.1, k = 0

b) f(x) = x2 + x,

f(x) = (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) = (2x)

_____________

C = 1, k = 1

_____________

C = 2, k = 1

_____________

C = 2, k = 2

_____________

C = 0.5, k = 2

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

C = 1, k = 1

_____________

C = 1, k = 16

_____________

C = 2, k = 16

_____________

C = 1, k = 256

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

f)

f(x) = (lg(x))

f(x) = (x!)

Assume x N for this problem only

_____________

C = 1, k = 1

_____________

C = 1/4, k = 2

_____________

C = 0.5, k = 4

_____________

C = 2, k = 0

f(x) = 7 + 1/x,

f(x) = (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 2n, 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 2n 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+1

F) W1 - W0 = n2

G) W1 - W0 = lg((1+lg(n))/lg(n)

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

I) W1 - W0 = lg(n)

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

K) W1 / W0 = 2

L) W1 / W0 = 4

M) W1 / W0 = 2n

N) W1 / W0 = 2n+1

O) W1 / W0 = lg(n)

P) W1 / W0 = 2n

Q) W1 / W0 = n2

R) W1 / W0 = lg(n2)

S) W1 / W0 = 2 + 2/lg(n)

T) W1 / W0 = 2 + lg(n)

U) W1 / W0 = 2 lg(n)

___________ a) 2

___________ b) lg n

___________ c) n

___________ d) 2n

___________ e) n lg n

___________ f) n2

___________ g) 2n

Scratch Paper

Potrebbero piacerti anche