Vous êtes sur la page 1sur 4

Algorithms Homework Fall 2000

2.1-1 Let f(n) and g(n) be asymptotically nonnegative functions. Using the basic definition of notation, prove that max(f(n), g(n)) ( f(n) ! g(n)). Show: 0 c1(f(n) + g(n)) max(f(n), g(n)) c2(f(n) + g(n)) max(f(n), g(n)) c2(f(n) + g(n)), since f(n) and g(n) are as m!toticall non"negati#e$ %here&ore, c2 ' 1 and n0 ' 1 max(f(n), g(n)) ( (f(n) + g(n)), since the maxim)m #al)e o& ( (f(n) + g(n)) ' max(f(n), g(n)) %here&ore, c1 ' ( 2.1-2 "ho# that for any real constants a and b, #here b $ %, (n ! a)b (nb) &ote' (a ch b) means *a choose +, &or integers a and b (n + a)b ' nb + (b ch 1)nb1a + (b ch 2)nb2a2 + ( + ab So nb is the leading term in the !ol nomial$ - the S)m .)le (!ro#en in /xercise 2$1"1) the leading term sets the #al)e$ %here&ore, (n + a)b ' (nb) 2.2-1 "ho# that if f(n) and g(n) are monotonically increasing functions, then so are the functions f(n) ! g(n) and f(g(n)), and if f(n) and g(n) are in addition nonnegative, then f(n) ) g(n) is monotonically increasing. 0& two monotonicall increasing &)nctions are added together, the s)m m)st also +e monotonicall increasing since there is nothing in the s)m that decreases either o& them$ Since g(n) is monotonicall increasing, once it is e#al)ated at an gi#en !oint and a #al)e is !rod)ced and this #al)e is &ed into another monotonicall increasing &)nction, f(n), the res)lt m)st +e monotonicall increasing + the de&inition o& a monotonicall increasing &)nction$ 0& the res)lts o& two &)nctions are the same sign, then the !rod)ct o& these res)lts will +e !ositi#e$ Since +oth f(n) and g(n) are non"negati#e and monotonicall increasing, the !rod)ct o& these two m)st also +e monotonicall increasing +eca)se there is nothing to decrease them$

*+,-L./" 2-1 0symptotic behavior of polynomials Let p(n) di % aini #here ad > %, be a degree-d polynomial in n, and let k be a constant. Use the definitions of the asymptotic notations to prove the follo#ing properties. a) 1f k d, then p(n) O(nk).

p(n) ' a1nd + a2nd"1 + 1 Since k d, k d 0 %here&ore, nk grows as &ast or &aster than nd %here&ore, p(n) ' O(nk) Alternati#el : p(n) d(adnd), &or some large n %here&ore, + setting c ' d d(adnd) ' O(nd) %here&ore, since k d d(adnd) ' O(nk) %here&ore, since p(n) d(adnd) p(n) ' O(nk) d) 1f k > d, then p(n) o(nk).

2et f(n) ' d(adnd) p(n) limn f(n)2nk ' limn d(adnd)2nk ' limn d(adnd-k) ' limn dad2nk"d ' 0 %here&ore, p(n) ' o(nk) 2-3 0symptotic notation properties Let f(n) and g(n) be asymptotically positive functions. *rove of disprove each of the follo#ing con4ectures. a) f(n ) O(g(n)) implies g(n) O(f(n)).

FA2S/$ 2et f(n) ' n2 and g(n) ' n3 %hen, f(n) ' O(g(n)), +)t g(n) O(f(n))

b)

f(n) ! g(n)

(min(f(n), g(n))).

FA2S/$ 2et f(n) ' n2 and g(n) ' n3 %hen min(f(n), g(n)) ' n2 0& f(n) + g(n) ' n2 + n3 ' ( n2) ' (min(f(n), g(n))), then c1 and c2 >0 and n0 0 s)ch that 0 c1n2 n2 + n3 c2n2, &or all n n0 -)t, 1 + n > c2, &or s)&&icientl large n So, this is a contradiction$ c) f(n) O(g(n)) implies lg(f(n)) f(n) 1 for all sufficiently large n. O(lg(g(n))), #here lg(g(n)) > % and

%.4/$ 5i#en: f(n) cg(n) Show: lg(f(n)) clg(g(n)) lg(f(n)) clg(g(n)) ' lg(f(n)) lg(g(n))c Since we are gi#en that lg(g(n)) > 0, then c m)st +e !ositi#e$ %here&ore, lg(g(n))c m)st grow &aster than lg(f(n)) as n goes to , and is there&ore an as m!totic )!!er +o)nd$ d) f(n ) O(g(n)) implies 2f(n) O(2g(n)).

FA2S/$ 2et f(n) ' n and g(n) ' n62, then f(n) ' O(g(n)), with c 2 Howe#er, limn 2n/262n < 1 %here&ore, 2f(n) O(2g(n)) e) f(n ) O((f(n))2).

FA2S/$ 2et f(n) ' 16n2 Since, 16n2 > c(16n2)2 ' c6n7 &or s)&&icientl large n, f(n) O((f(n))2) f) f(n ) O(g(n)) implies g(n)

(f(n)).

%.4/$ - trans!ose s mmetr $ f(n) ' O(g(n)) im!lies g(n) ' (f(n)) means that f(n) c(g(n)) im!lies g(n) c(f(n)) 0&, f(n) c(g(n)), then, 16c f(n) g(n), which means that g(n) c(f(n))

g)

f(n )

(f(n22)).

FA2S/$ f(n) ' (f(n62)) means that c1 and c2 >0 and n0 0 s)ch that 0 c1f(n62) f(n) c2f(n62), &or all n n0 2et f(n) ' 2n, then c1 and c2 >0 and n0 0 s)ch that 0 c12n/2 2n c22n/2, &or all n n0 Howe#er, 2n grows &aster than 2n/2 &or s)&&icientl large n. %here&ore, the constants c1 and c2 do not exist$