Sie sind auf Seite 1von 5

TUTORIAL 1 Asymptotic notation (10 minutes)

The notations we use to describe the asymptotic running time of an algorithm.

(g(n)) is the set of functions f(n) such that there exist positive constants c1, c2 and n0 such that 0c1 g(n) f(n) c2 g(n) for all nn0 notation bounds a function within constant factors c2g(n) f(n) c1g(n) n0 !xample" #n2 $ 2n $ 10 % (n2)

O:
& (g(n)) is the set of functions f(n) such that there exist positive constants c and n0 such that 0 f(n) c g(n) for all nn0 & gives an upper bound for a function within a constant factor. 'n the figure c%c2 !xample" 2n % &(n2)

(g(n)) is the set of functions f(n) such that there exist positive constants c and n0 such that 0 c g(n) f(n) for all nn0 gives a lower bound for a function within a constant factor. 'n the figure c%c1 !xample" #n2 % (n)

Basic Probability (20 minutes)


1. ample pace is the set of all possible outcomes of an experiment. !xample" tossing two coins has (%)**,T*,*T,TT+

T* ** TT *T !lementary events

,sually we are interested in collections of elementary events, which are called e!ents T* ** TT *T -t least one head .is observed/

2. Probability is the measurment of li0elihood of uncertain events to occur The probability of an event -, 1r)-+%(2 of elementary events in -)3(2elementary events in () 'f the elementary events are e4ually li0ely. Probability a"ioms that the assignment of probabilities must satisfy" 1. 01r)-+1, for every -. 2. 1r)(+%1, an outcome in the sample space is certain to occur. 3. 'f -1,5, -n are mutual exclusive events pairwise" -i -6 % Then 1r)-15-n + % 1r)-1+$5$1r)-n + Rules o# probabilities 1. 1r)-7 + % 1r)-+$1r)7+81r)-7+ 7

2. 1r)-9+%181r)-+. 7y probability axioms 2,# $on%itional probabilities :onditional probability of - given 7 1r)-;7+%1r)-7+31r)7+ < 7 < < < < < < < < -

;(;%=, ;-;%>, ;7;%?, ;-7;%2 1r)-;7+%(23=)3(?3=)%23? The new sample space is defined by 7 so intuitively in 7 only 2 events satisfy -. In%epen%ent e!ents 1r)-7+%1r)-+ 1r)7+ !4uivalently if 1r)7+0 then 1r)-;7+%1r)-+ !xample 2 coin tosses " - % first toss is *ead 7 % second toss isTail *T @ot 'ndepended events"

1r)-7+%0

1r)-7+%-

#. Ran%om &ariable is a variable whose value is determined in some way by chance. !xample" @umber of people in a line at a ban0 at some point. Aathematically we thin0 it as a function that maps the points of the sample space into the set of real numbers. !xample" Two tosses of a fair coin" Bet < be the random variable that denotes the number of heads occurring in the two tosses. 1ossible values for <"0,1,2 ( TT T* *T **

Ceal @umbers

1. Discrete random variables" all possible values are countable (example before) 2. :ontinuous random variables. Their values are spread continuously over intervals of real numbers. !xample" atmospheric temperature at noon each day. E0:, 2F:G He define the event <%x for some value x, to be the set of elementary events in ( that map to x by <. " )s( " <(s)%x+ Probability %ensity #unction is a function that assigns a probability to each of the possible values of < " f<(x) % 1r)<%x+ !xample" Bet < be the random variable that denotes the number of heads occurring in the two tosses. " 0 1 2 #(") 13> 132 13> 1roperties" 1. 0 f(x) 1 2. x f(x) % 1 Two random variables < and I are in%epen%ent, if for all values x of < and all values y of I 1r)<%x and I%y+ % 1r)<%x+ 1r)I%y+ 4. '"pecte% &alue: -verage value of a random variable !E<G % x x f(x) !xample" !E<G% x%0 2 x f(x) % 0 (13>) $ 1 (132) $ 2 (13>) % 1 This implies that there will be 1 head, on average, in 2 tosses of a fair coin. 1roperties" 1. !E<$IG % !E<G $ !EIG 2. !Ea <G % a !E<G, for any constant a #. 'f <, I are independent random variables, then !E<IG%!E<G!EIG

Basic Recurrences (20 minutes)


- recurrence is am e4uation or ine4uality that describes a function in terms of its value on smaller inputs. !xample 1" T(n) % T(n81) $ f(n) for some function f(n) that has a closed8form sum, where T(0) % some constant.

Iteration met(o%: Cecurrences of the above form can be solved using the iteration method. This means that we simply unwind the recursion" since T(n) % T(n81) $ f(n), it must be the case that T(n81) % T(n82) $ f(n81). Then we can substitute for T(n81) in the first e4uation" T(n) % (T(n82) $ f(n81)) $ f(n). He can continue this until we 6ust have T(0) on the right side. (o T(n) % T(0) $ f(1) $ f(2) $ 5 $ f(n). (ince f(n) has a closed8form sum, the right hand side can be simplified.

)aster met(o% provides a way for solving recurrences of the form T(n)%aT(n3b)$f(n), a 1,bJ1, f(n) is an asymptotically positive function. This is the running time of an algorithm that divides a problem of siKe n into a subproblems, each of siKe n3b. each of the a subproblems are solved recursively each in time T(n3b). !xample 2" (tate the master theorem without proof and give an example li0e T(n) % 2T(n32) $ &(n) (20 minutes)

Das könnte Ihnen auch gefallen