You are on page 1of 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(x 0 – a) B) lg(a - x 0 ) C) lg(a) D) lg(x 0 ) E) lg(x 0 / a) F) lg(a / x 0 ) G) log x0 (a) H) log a (x 0 ) I) lg(log x0 (a)) J) lg(log a (x 0 )) K) log a (x 0 )/lg(a) L) a - x 0 M) log x0 (a)/lg(a) N) log x0 (a)/lg(x 0 ) O) x 0 + a P) x 0 – a Q) -lg(log x0 (a)) R) -lg(log a (x 0 )) S) x 0 ^ a T) a ^ x 0 U) -log x0 (a)/lg(a) V) -log x0 (a)/lg(a) W) x 0 X) ∞

a)

b)

c)

d)

e)

x

x 0 while x > a

end

x

x -

1

x

x 0 while x < a

end

x

2x

x

x 0 while x < a

end

x

x /

2

x

x 0 while x < a

end

x x 2

x

x 0 while x > a

end

x

where:

and

x 0 a < x 0

a

are integers

where:

x 0

0 < x 0

and

a

are real numbers

< a

where:

x 0

0

where:

x 0

1

 and a are real numbers < a < x 0 < 1 and a are real numbers < a < x 0

where:

x 0

1 <

and

a a < x 0

are real numbers

2. Find the least integer n such that f(x) possible, write “Impossible”.

is

O(x n )

a) f(x) = 2x 2 + x 3 log x

b) f(x) = 3x 5 + (log x) 4

for each of these functions. If no such

n

is

c) f(x) = (x 4 + x 2 + 1)/(x 4 + 1)

d) f(x) = (x 3 + 5log x)/(x 4 + 1)

e) f(x) = x / log x

f) f(x) = x 2 (log x) 8 + x 2

g) f(x) = x 2 (8x 2 + 3x + 5log x)

 h) f(x) = √ + √ i) f(x) = √ / √

j) f(x) = x 5 (

+ 1/x)

3.

Recall that to establish a big-Ω relationship, we find C and k such that f(x) ≥ C • g( )

for

the given C and k establish a big-Ω relationship. Otherwise, write “False”.

x > k. Assume C, k and x are real numbers. For each of the following blanks, write “True” if

a) f(x) = x + 0.5,

f(x) = Ω(x)

C = 1,

k

= 1

C = 1.5, k = 3

C = 0.5, k = 1

C = 0.1, k = 0

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

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

f(x) = Ω(x 2 )

 C = 2, k = 0 C = 2, k = 1 C = 2, k = 2 C = 0.5, k = 2 f(x) = Ω(2 x ) C = 1, k = 1 C = 2, k = 1 C = 2, k = 2 C = 0.5, k = 2

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

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

f(x) = Ω(lg(x))

C =

1,

k

= 1

C = 2, k = 16

f(x) = Ω(x!)

Assume

x ∈ N

C =

1, k = 16

C = 1, k = 256

for this problem only

 C = 1, k = 1 C = 1/4, k = 2 C = 0.5, k = 4 C = 2, k = 0 f) 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

with input size

size 2n and let W 0 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).

n

to

2n, assuming that the number of milliseconds the algorithm uses to solve the problem

n

is each of the quantities expressed below? Let W 1 denote the runtime with input

A)

D)

G)

J) W 1 - W 0 = lg(n+1) lg(n)

W

W

1

1

- W 0 - W 0

= 0

= n

W 1 - W 0 = lg((1+lg(n))/lg(n)

M) W 1 / W 0 = 2n

P) W 1

/ W 0

= 2 n

S)

W 1 / W 0 = 2 + 2/lg(n)

B) W 1 - W 0

E) W 1 - W 0 = 2n+1

H) W 1 - W 0 = lg(1+lg(n))

K) W 1 / W 0

= 1

= 2

N) W 1 / W 0 = 2n+1

Q) W 1 / W 0

= n 2

T) W 1 / W 0 = 2 + lg(n)

C) W 1

F) W 1 - W 0 = n 2

I) W 1 - W 0 = lg(n)

L) W 1

- W 0

= 2

/ W 0

= 4

O) W 1 / W 0 = lg(n)

R) W 1 / W 0 = lg(n 2 )

U) W 1 / W 0 = 2 lg(n)

a) 2

b) lg n

c) n

d) 2n

e) n lg n

f) n 2

g) 2 n

Scratch Paper