Sie sind auf Seite 1von 3

CS5114 Spring 2010

Solution to Homework Assignment 2

1.

Manber 3.5

a. f (n) = g(n)
limn

f (n)
g(n)

= limn

100n+log n
n+(log n)2

= 100

b. f (n) = g(n)
limn

f (n)
g(n)

= limn

log n
log(n2 )

= limn

n
(log n)3

log n
2 log n

1
2

c. f (n) = (g(n))
limn

f (n)
g(n)

= limn

d. f (n) = (g(n))
limn

log f (n)
log g(n)

= limn

log nlog log n


log nlog log n

e. f (n) = (g(n))
limn

f (n)
g(n)

= limn

n2
(log n)5

f. f (n) = O(g(n))
limn

f (n)
g(n)

= limn n( 32 )n = 0

2. Provide an exact solution to the following recurrence, assuming that n has a nice form. What
is a nice form in this context? Prove that your solution is correct.
T (2) = 1

T (n) = T ( n) + 1

The nice form is n = 22 , i = 0, 1...


Thus the equations turn to
0

T (22 ) = 1
i

2i

i1

T (22 ) = T ( 22i ) + 1 = T (2 2 ) + 1 = T (22

)+1

We get:
i

i1

T (22 ) = T (22

2i2

= T (2

)+1
)+2

=
0

= T (22 ) + i
= T (2) + i
= i+1
T (n) = log log n + 1
Proof of correctness: We use mathematical induction to prove.
0
0
Base case: i = 0, T (22 ) = T (2) = 1, 0 + 1 = 1, T (22 ) = 0 + 1
i
Induction hypothesis: Assume for all natural numbers up to i, T (22 ) = i + 1. Then,
i+1

T (22

) = T (22 ) + 1
= i+1+1
= i+2

By mathematical induction, the result is correct.

3.

Manber 3.22

i1

a. Let dne = 22 , so T (22 ) = 4T (22

) + 1. Then,

i1

T (22 ) = 4T (22

)+1

2i2

= 4(4T (2
i

= 4 +4

i1

logX
log n

+ ... + 41 + 40

4i

i=0
log log n

= (4

= ((2

) + 1) + 1

log log n 2

) )

= ((log n) )
= (log2 n).
i

b. Let n = 22 , and denote T (22 ) as S(i),


We use mathematical induction to prove that when i 2,
i

i1

2 22 S(i) 2 22 + 100 22i = 2 22 + 100 22


2

Base case: i = 2,
2

S(2) = T (22 )
1

= 2T (22 ) + 2 22 = 2(2T (22 ) + 2 4) + 32


= 2(2 1 + 2 4) + 32
= 52
22
2i

2 2 + 100 2

2i

2i1

= 2 16 = 32

= 2 16 + 100 16 = 32 + 400 = 432

So, when i = 2, the inequality holds.


Induction hypothesis: Assume for a natural number up to i, the inequality holds.
Then, we try to prove that for i + 1, the inequality holds too.
i+1

Since S(i + 1) = T (22


For the other side,

i+1

) = 2T (22 ) + 2 22

i+1

S(i + 1) = T (22

i+1

) = 2T (22 ) + 2 22

i1

2(2 22 + 100 22
i+1

2 22
i1

Since when i 2, 200 22

i+1

and T (22 ) > 0, we have 2 22

i+1

) + 2 22

i1

+ 4 22 + 200 22

96 22 ,
i+1

S(i + 1) 2 22

+ 100 22

By mathematical induction, the inequality holds for a big enough i, so

2n T (n) 2n + 100 n, n 16
So the asymtotic behavior of T (n) is (n).

S(i + 1).

Das könnte Ihnen auch gefallen