This preview has intentionally blurred sections. Sign up to view the full version.
View Full DocumentThis preview has intentionally blurred sections. Sign up to view the full version.
View Full Document
Unformatted text preview: (1) ECE608, Homework #2 Solution CLR 3.1—2 To show that (n + (1)” = 9(nb), we want to ﬁnd constants cl, 02, and no > 0 such
that 0 S clnb 3 (71+ (1)” S anb for all n 2 no. Note that n+a S n+ a 3 2n, when
n n n
a S n, andnl—aZn— a 2 5, when a S Thus, 03 E S n+a£ 2n, when
n 2 2a. Since b > 0, the inequality continues to hold when all parts are raised to
l
the power of b: 0 S S (n+a)b S (2n)b and 0 S (E)be S (n+a)b S 2%". Thus,
1 01 : (if, 02 : 2b, and no : 2a satisfy the deﬁnition. Another way to look at this is as follows: 0 S cm" S (n + (1)” S cm”
i a
0 S clnb S (n(1+ —))b S anb
n
l a
0 S club S 71" (1 + EY’ S anb
i ogc1g(1+9)”302
n Let no 2 2a, then cl = G)" and c2 2 (gr. CLR 3.1—6 Prove that the running time of an algorithm T(n) = 9(g(n)) if and only if the worst—
case running time is O(g(n)) and the best—case running time is Proof (<=) Let T(n) be the running time of the algorithm. Then, if the worst—case running time
of the algorithm is O(g(n)), it follows that T(n) = O(g(n)), because the algorithm
cannot operate more slowly than the worst case. If the best—case running time of the
algorithm is Q(g(n)), it also follows that T(n) : Q(g(n)), because it is impossible for the algorithm to operate faster than the best case.
Hence, by the Theorem 3.1 in CLR, T(n) = @(g(n)) (=>)
If the running time T(n) : 9(g(n)), there exist constants 01 > 0, co > 0, and no > 0 1 such that 0 S clg(n) S T n) S c2901) for all n 2 no. Thus, by the deﬁnition of
T 0(g(n)) and T(”) 9(900) CLR 3.1—7
Prove that w(g(n)) ﬂ 0(g(n)) is the empty set.
Proof If w(g(n)) ﬂ 0(g(n)) is non—empty then Ef(n) such that E 0(g(n)) and E For every E o(g(n)) we know that lim7H°o M = 0. But such an 9(")
f ¢ w(g(n)) because that requires limnhoo 33(3)) 2 00. Thus by contradiction we
know that w(g(n)) ﬂ 0(g(n)) must be empty. CLR 3.2—2 Proof l alogbc:(clogca)logbc :c(logcalogbc) :Cﬁﬁ :clogba CLR 3.2—3 Stirling’s approximation: n! = x/27rn(%)"(1 + (1) 1g(n!) : @(nlgn)
Proof
By Stirling’s approximation, W) = 1g{¢27r—n<§)”(1+e(%»}
1g27r lgn —l1 1 I
2 2 ngn nge Because nlgn is the dominant term in the above equation, lg(n!) : 9(n1g (2) n! = w(2")
Proof
By Stirling’s approxmation,
, n! , n n
#1330; — $590 2W2? (1+ 99,»
, (x/27r)n("+%
11m ,,
n—>oo : 00 Hence, n! = w(2"). (3) n! = 0(n") Proof By Stirling’s approxmation, 1
n )) l
lim i lim x/27rn(l)"(1+@(
n—>oo In" 'n—)oo e
, x/27rn
2 11m n—>oo en . x/ﬁ _ I ' I
_ n11_)m 2W6" by L Hosp1tal s rule
: 0
Hence, n! = 0(n").
(6) CLR 3.25
lg*(lg n) is asymptotically larger than lg(lg* n).
Proof Let m 2 lg* n, and assume that n 2 4. Hence lg*(lg n) = m — 1. We are now com
paring between lg(lg* n) = lgm and m — 1. Clearly m — 1 is asymptotically larger
than lg m when m is sufﬁciently large. Thus we can conclude that lg*(lg n) is asymp—
totically larger than lg(lg* (7) CLR 3—2 (refer to Figure31 for table) (a) If f(n) 2 lg,“ n, then f’(n) = W; hence, by using L’Hopital’s rule as follows: , lgkn , klgk_1nlge , [k(k — 1)lgk_2nlg26] _ kllgke
hm :hm—:hm—::hm :
naoo “6 naoo enf naoo 521,16 naoo Eknﬁ 0, we conclude that lg’c n = 0(n‘) => hence 0(n‘).
(b) If f = c", then f’ = c"ln 0; hence, by using L’Hopital’s rule as follows:
k k—1 l
lim ” _ 11m k” __ lim '9', _0,
n—>oo c" n—mo c" In c n—>oo on In c
we conclude that nk : 0(c") => hence 0(0").
(0) lim ﬂ : lim 71% n—>oo nsin(n) n—>oo —sin (n) Since sin(n) oscillates between +1 and —1, n; _Sin(") takes a value between 717% a . .
and n+2. Thus, an asymptotic comparlson cannot be made. 2”
(d) 71135.10 271/2 : mo 2"/2 : 00. Thus, 2n : w(2”/2) => 9(2n/2).
1g(m)
(e) lim “1 = lim 1 = 1, because nlgm) 2 mm"). Thus, #30") = 9(mlg(")) =>
n—>oo m g(") n—>oo n1g(m) : 0(mlg(n)) and nlg(m) : 9(mlg(n)). 3 (f) lgn! = 9(nlgn) and lg(n") = nlgn. Thus, lgn! = @(nlgn) = 9(lg(n")) and
we have lg n! =O(lg(n")) and lg n! = Q(lg(n")). item 0 0 9 w
a yes yes no no
b yes yes no no
0 no no no no
(1 no no yes yes
e yes no yes no
f yes no yes no yes
Figure 1: Table for Problem CLR 3—2. (8) CLR 33 (a) Ranking by asymptotic growth rate, equivalent classes are enclosed by ’[ ]’. [1,n1/1g"],1g(1g* n), [1g"(1gn),1g*(n)],21g"",1nlnn,\/Tgn,1nn,1g2 n, 2" 21”, mfg",
21g", [nlgna 114W]: [41“: n2], n3, (1%”)!7 [nlglg'h (190ml, (3/2)", 2", n2", 6", 71!, (n+1)!, 22", 22"+ (b) 22"+5(sin(n) + 1)
(9) CLR 34 (a) False. Let g(n) = n2 and f(n) = n, so that f(n) = O(g(n)), i.e., n =O(n2). But
this does not imply that g(n) : O(f(n)) as n2 7é (b) False. Let f(n) : n2, g(n) : n, then f(n) + g(n) : n2 + n : @(nz).
O(min(f(n),g(n))) = @(n) and 0(n2) 7€ Thus, K”) + $00 7é 9011111601), $00)) (0) If we assume that ﬂu) and g(n) represent the time complexities for an algorithm, then they are monotonically increasing functions. Given these assumptions, the
claim is true. Given f(n) : O(g(n)) and f(n) 2 1, we know 1 S f(n) S c1g(n)
for all n 2 no and 01 > 0. Since f(n) 2 1, lg(f(n)) 2 0, lg(g(n)) is positive, and
lg(f(n)) is positive, lg 1 S lg(f(n)) S lg(clg(n)). :5 0 s 1g(f(n)) S 1g 01 +1g(g(n))
=> for 61 Z 1 and 0 S lg(f(n)) S c21g(g(n)), for (:2 Z 1. (d) (g) (11) False. Given f(n) = O(g(n)), we have 0 S f(n) S cg(n) for positive 0, no, and
n > no. Then if it is true that 0 S 2f(") S c2g(") for some 0, no, and n > no, 2f(n)
then 0 g g c and 0 g 2f(")’g(") g c. 2w»)
However, if f(n) = 5n and g(n) = n, then 0 S 24" S c is impossible.
f
If 0 g f(n) g c(f(n))2 for some positive 0, no and n 2 no, then 0 S S c and 0 S i S c.
ﬁn) With additional assumptions as stated in (c), this claim is true. But without —, this claim is false.
n True. f(n) : O(g(n)) implies that for some positive c1 and no, 0 S f(n) S
c1g(n), for all n 2 no. g(n) : implies that for some positive c2 and no,
0 g 02f(n) g g(n), for all n 2 no. Kn) those additional assumptions about f(n), then if f(n) = c, 0 S c < oo, given that f(n) = ﬁn) gm) lim
n—>oo Case 1: If c : 0, lim : 0. Here lim : 00, so f(n) is a lower bound n—>oo n—>oo of g(n).
f 1 Case 2: If c > 0, lim ﬂ : 0. Here lim ﬂ : — : c', where c' > 0. naoo naoo (3
Based on those two cases, g(n) = False. Consider f(n) = 2" and = 2%, then if f(n) 2 96(3)), we must have
2" 3 C22% :> 2% < 02 which is impossible as there is no Cg for ﬁxed no. True. 0 S c1f(n) ; f(n) + o(f(n)) S 02f(n) own» 3 but hm own»
ﬁn) "v°° ﬁn)
Hence, there is a cl, say 1 and a 02 for sufﬁciently large n and n 2 no. => 0 S 01 S 1 + = 0 by the deﬁnition of ...
View
Full
Document
This note was uploaded on 01/10/2012 for the course ECE 565 taught by Professor Pai during the Fall '11 term at Purdue.
 Fall '11
 PAI

Click to edit the document details