Recursion and Recurrences


 Osborne Maxwell
 2 years ago
 Views:
Transcription
1 Chapter 5 Recursio ad Recurreces 5.1 Growth Rates of Solutios to Recurreces Divide ad Coquer Algorithms Oe of the most basic ad powerful algorithmic techiques is divide ad coquer. Cosider, for example, the biary search algorithm, which we will describe i the cotext of guessig a umber betwee 1 ad 100. Suppose someoe picks a umber betwee 1 ad 100, ad allows you to ask questios of the form Is the umber greater tha k? where k is a iteger you choose. Your goal is to ask as few questios as possible to figure out the umber. Your first questio should be Is the umber greater tha 50? Why is this? Well, after askig if the umber is bigger tha 50, you have leared either that the umber is betwee oe ad 50, or that the umber is betwee 51 ad 100. I either case have reduced your problem to oe i which the rage is oly half as big. Thus you have divided the problem up ito a problem that is oly half as big, ad you ca ow (recursively) coquer this remaiig problem. (If you ask ay other questio, oe of the possible rages of values you could ed up with would more tha half the size of the origial problem.) If you cotiue i this fashio, always cuttig the problem size i half, you will be able to get the problem dow to size oe fairly quickly, ad the you will kow what the umber is. Of course it would be easier to cut the problem exactly i half each time if we started with aumber i the rage from oe to 128, but the questio does t soud quite so plausible the. Thus to aalyze the problem we will assume someoe asks you to figure out a umber betwee 0 ad, where is a power of 2. Exercise Let T () be umber of questios i biary search o the rage of umbers betwee 1 ad. Assumig that is a power of 2, get a recurrece of for T (). For Exercise we get: T () = T (/2)+1 if 2 1 if =1 (5.1) That is, the umber of guesses to carry out biary search o items is equal to 1 step (the guess) plus the time to solve biary search o the remaiig /2 items. 159
2 160 CHAPTER 5. RECURSION AND RECURRENCES What we are really iterested i is how much time it takes to use biary search i a computer program that looks for a item i a ordered list. While the umber of questios gives us a feel for the amout of time, processig each questio may take several steps i our computer program. The exact amout of time these steps take might deped o some factors we have little cotrol over, such as where portios of the list are stored. Also, we may have to deal with lists whose legth is ot a power of two. Thus a more realistic descriptio of the time eeded would be T () T ( /2 )+C1 if 2 C 2 if =1, (5.2) where C 1 ad C 2 are costats. It turs out that the solutio to (5.1) ad (5.2) are roughly the same, i a sese that will hopefully become clear later. This is almost always the case; we will come back to this issue. For ow, let us ot worry about floors ad ceiligs ad the distictio betwee thigs that take 1 uit of time ad thigs that take o more tha some costat amout of time. Let s tur to aother example of a divide ad coquer algorithm, mergesort. Ithis algorithm, you wish to sort a list of items. Let us assume that the data is stored i a array A i positios 1 through. Mergesort ca be described as follows: MergeSort(A,low,high) if (low == high) retur else mid = (low + high) /2 MergeSort(A,low,mid) MergeSort(A,mid+1,high) Merge the sorted lists from the previous two steps More details o mergesort ca be foud i almost ay algorithms textbook. Suffice to say that the base case (low = high) takes oe step, while the other case executes 1 step, makes two recursive calls o problems of size /2, ad the executes the Merge istructio, which ca be doe i steps. Thus we obtai the followig recurrece for the ruig time of mergesort: T () = 2T (/2) + if >1 1 if =1 (5.3) Recurreces such as this oe ca be uderstood via the idea of a recursio tree, which we itroduce i the followig. This cocept will allow us to aalyze recurreces that arise i divideadcoquer algorithms, ad those that arise i other recursive situatios, such as the Towers of Haoi, as well. A recursio tree for a recurrece is a visual ad coceptual represetatio of the process of iteratig the recurrece.
3 5.1. GROWTH RATES OF SOLUTIONS TO RECURRENCES 161 Figure 5.1: The iitial stage of drawig a recursio tree /2 Recursio Trees We will itroduce the idea of a recursio tree via several examples. It is helpful to have a algorithmic iterpretatio of a recurrece. For example, (igorig for a momet the base case) we ca iterpret the recurrece T () =2T (/2) + (5.4) as i order to solve a problem of size we must solve 2 problems of size /2 ad do uits of additioal work. Similarly we ca iterpret T () =T (/4) + 2 as i order to solve a problem of size we must solve 1 problems of size /4 ad do 2 uits of additioal work. We ca also iterpret the recurrece T () =3T ( 1) + as i order to solve a problem of size, wemust solve 3 subproblems of size 1 ad do additioal uits of work. I Figure 5.1 we draw the begiig of the recursio diagram for (5.4). For ow, assume is apower of2.arecursio tree diagram has three parts. O the left, we keep track of the problem size, i the middle we draw the tree, ad o right we keep track of the work doe. We draw the diagram i levels, each level of the diagram represetig a level of recursio. Equivaletly, each level of the diagram represets a level of iteratio of the recurrece. So to begi the recursio tree for (5.4), we show i level 0 o the left that we have problem of size. The by drawig aroot vertex with two edges leavig it, we show i the middle that we are splittig it ito 2 problems. We ote o the right that we do uits of work i additio to whatever is doe o the two ew problems we created. So that the diagram cotais the relevat iformatio, we fill i part of level oe. We draw two vertices i the middle represetig the two problems ito which we split our mai problem ad show o the left that each of these problems has size /2. You ca see how the recurrece is reflected i levels 0 ad 1 of the recursio tree. The top vertex of the tree represets T (), a the ext level we have two problems of size /2, givig us the recursive term 2T (/2) of our recurrece. The after we solve these two problems we retur to level 0 of the tree ad do additioal uits of work for the orecursive term of the recurrece.
4 162 CHAPTER 5. RECURSION AND RECURRENCES Figure 5.2: Four levels of a recursio tree. /2 /2 + /2 = /4 /4 + /4 + /4 + /4 = /8 8(/8) = Now we cotiue to draw the tree i the same maer. Fillig i the rest of level oe ad addig a few more a few more levels, we have Figure 5.2. Let us summarize what the diagram tells us so far. At level zero (the top level), uits of work are doe. We see that at each succeedig level, we halve the problem size ad double the umber of subproblems. We also see that at level 1, each of the two subproblems requires /2 uits of additioal work, ad so a total of uits of additioal work are doe. Similarly level 2 has 4 subproblems of size /4 ad so 4(/4) uits of additioal work are doe. To see how iteratio of the recurrece is reflected i the diagram, we iterate the recurrece oce, gettig T () = 2T (/2) + T () = 2(2T (/4) + /2) + T () = 4T (/4) + + =4T (/4) + 2 If we examie levels 0, 1, ad 2 of the diagram, we see that at level 2 we have four vertices represetig four problems each of size /4. This gives us the recursive term that we got after iteratig the recurrece. However after we solve these problems we retur to level 1 where we twice do /2 additioal uits of work ad to level 0 where we do aother additioal uits of work. I this way each time we add a level to the tree we are showig the result of oe more iteratio of the recurrece. We ow have eough iformatio to be able to describe the recursio tree diagram i geeral. To do this, we eed to determie, for each level, three thigs umber of subproblems, size of each subproblem, total work doe. We also eed to figure out how may levels there are i the recursio tree.
5 5.1. GROWTH RATES OF SOLUTIONS TO RECURRENCES 163 We see that for this problem, at level i, wehave 2 i subproblems of size /2 i. Further, sice a problem of size 2 i requires 2 i uits of additioal work, there are (2 i )[/(2 i )] = uits of work doe per level. To figure out how may levels there are i the tree, we just otice that at each level the problem size is cut i half, ad the tree stops whe the problem size is 1. Therefore there are log 2 +1levels of the tree, sice we start with the top level ad cut the problem size i half log 2 times. 1 We ca thus visualize the whole tree i Figure 5.3. Figure 5.3: A fiished recursio tree diagram. log +1 levels /2 /4 /2 + /2 = /4 + /4 + /4 + /4 = /8 8(/8) = 1 (1) = The bottom level is differet from the other levels. I the other levels, the work is described by the recursive part of the recurrece, which i this case is T () =2T (/2) +. Atthe bottom level, the work comes from the base case. Thus we must compute the umber of problems of size 1 (assumig that oe is the base case), ad the multiply this value by T (1). For this particular recurrece, ad for may others we will see, it turs out that if you compute the amout of work o the bottom level as if you were computig the amout of additioal work required after you split a problem of size oe ito 2 problems (which, of course, makes o sese) it will be the same value as if you compute it via the base case. Had we chose to say that T (1) some costat other tha 1, this would ot have bee the case. We emphasize that the correct value always comes from the base case: it is just a coicidece that it sometimes also comes from the recursive part of the recurrece. The bottom level of the tree represets the fial stage of iteratig the recurrece; at this level we have problems each requirig work T (1) = 1, ad after we solve them we have to do all the additioal work from all the earlier levels. Thus iteratio of the recurrece tells us that the solutio to the recurrece is the sum of all the work doe at all the levels of the recursio tree. This is exactly how we use the recursio tree to write dow a solutio to a recurrece. The importat thig is that we ow kow exactly how may levels there are, ad how much work is doe at each level. Oce we kow this, we ca sum the total amout of work doe over all the levels, givig us the solutio to our recurrece. I this case, there are log 2 +1 levels, ad at each level the amout of work we do is uits. Thus we coclude that the total amout 1 To simplify otatio, for the remaider of the book, if we omit the base of a logarithm, it should be assumed to be base 2.
6 164 CHAPTER 5. RECURSION AND RECURRENCES Figure 5.4: A recursio tree diagram for Recurrece 5.5. log + 1 levels /2 /4 /2 /4 /8 /8 1 1 of work doe to solve the problem described by recurrece (5.4) is (log 2 + 1). The total work doe throughout the tree is the solutio to our recurrece, because the tree simply models the process of iteratig the recurrece. Thus the solutio to recurrece (5.3) is T () =(log + 1). More geerally, we ca cosider a recurrece that it idetical to (5.3), except that T (1) = a, for some costat a. Ithis case, T () =a + log, because a uits of work are doe at level 1 ad additioal uits of work are doe at each of the remaiig log levels. It is still true that, T () =Θ( log ), because the differet base case did ot chage the solutio to the recurrece by more tha a costat factor. Sice oe uit of time will vary from computer to computer, ad sice some kids of work might take loger tha other kids, it is the bigθ behavior of T () that is really relevat. Thus although recursio trees ca give us the exact solutios (such as T () =a+ log above) to recurreces, we will ofte just aalyze a recursio tree to determie the bigθ or eve, i complicated cases, just the bigo behavior of the actual solutio to the recurrece. I Problem?? we explore whether the value of T (1) actually iflueces the bigθ behavior of the solutio to a recurrece. Let s look at oe more recurrece. T () = T (/2) + if >1 1 if =1 (5.5) Agai, assume is a power of two. We ca iterpret this as follows: to solve a problem of size, wemust solve oe problem of size /2 ad do uits of additioal work. We draw the tree for this problem i Figure 5.4. We see i this figure that the problem sizes are the same as i the previous tree. The rest, however, is differet. The umber of subproblems does ot double, rather it remais at oe o each level. Cosequetly the amout of work halves at each level. Note that there are still log +1levels, as the umber of levels is determied by how the problem size is chagig, ot by how may subproblems there are. So o level i, wehave 1problem of size /2 i, for total work of /2 i uits.
7 5.1. GROWTH RATES OF SOLUTIONS TO RECURRENCES 165 We ow wish to compute how much work is doe i solvig a problem that gives this recurrece. Note that the additioal work doe is differet o each level, so we have that the total amout of work is ( + /2+/ = ( 1 log2 4 2) ) + +, which is times a geometric series. By Theorem 4.4, the value of a geometric series i which the largest term is oe is Θ(1). This implies that the work doe is described by T () =Θ(). We emphasize that there is exactly oe solutio to recurrece (5.5); it is the oe we get by usig the recurrece to compute T (2) from T (1), the to compute T (4) from T (2), ad so o. What we have doe here is show that T () =Θ(). We have ot actually foud a solutio. I fact, for the kids of recurreces we have bee examiig, oce we kow T (1) we ca compute T () for ay relevat by repeatedly usig the recurrece, so there is o questio that solutios do exist. What is ofte importat to us i applicatios is ot the exact form of the solutio, but a bigo upper boud, or, better, a BigΘ boud o the solutio. Exercise Fid a bigθ boud for the solutio to the recurrece 3T (/3) + if 3 T () = 1 if <3 usig a recursio tree. Assume that is a power of 3. Exercise Solve the recurrece T () = 4T (/2) + if 2 1 if =1 usig a recursio tree. Assume that is a power of 2. Covert your solutio to a bigθ statemet about the behavior of the solutio. Exercise Ca you give a geeral bigθ boud for solutios to recurreces of the form T () =at (/2) + whe is a power of 2? You may have differet aswers for differet values of a. The recurrece i Exercise is similar to the mergesort recurrece. Oe differece is that at each step we divide ito 3 problems of size /3. Thus we get the picture i Figure 5.5. Aother differece is that the umber of levels, istead of beig log 2 +1isow log 3 +1,so the total work is still Θ( log ) uits. Note that log b = Θ(log 2 ) for ay b>1. Now let s look at the recursio tree for Exercise Now, we have 4 childre of size /2, ad we get the Figure 5.6 Let s look carefully at this tree. Just as i the mergesort tree there are log 2 +1levels. However, i this tree, each ode has 4 childre. Thus level 0 has 1 ode, level 1 has 4 odes, level 2 has 16 odes, ad i geeral level i has 4 i odes. O level i each ode correspods to a problem of size /2 i ad hece requires /2 i uits of additioal work. Thus the total work o level i is 4 i (/2 i )=2 i uits. Summig over the levels, we get log 2 i=0 log 2 2 i = i=0 2 i.
8 166 CHAPTER 5. RECURSION AND RECURRENCES Figure 5.5: The recursio tree diagram for the recurrece i Exercise /3 /3 + /3 + /3 = log + 1 levels /9 9(/9) = 1 (1) = There are may ways to simplify that expressio, for example from our formula for the sum of a geometric series we get. log 2 T () = i=0 2 i = 1 2(log 2 ) = = 2 2 = Θ( 2 ). Figure 5.6: The Recursio tree for Exercise /2 /2 + /2 + /2 + /2 = 2 log + 1 levels /4 16(/4) = 4 1 ^2(1) = ^2
9 5.1. GROWTH RATES OF SOLUTIONS TO RECURRENCES 167 More simply, by Theorem 4.4 we have that T () =Θ2 log =Θ( 2 ). Three Differet Behaviors Now let s compare the trees for the recurreces T () =2T (/2) +, T () =T (/2) + ad T () =4T (/2) +. Note that all three trees have depth 1 + log 2,asthis is determied by the size of the subproblems relative to the paret problem, ad i each case, the size of each subproblem is 1/2 the size of of the paret problem. To see the differeces, i the first case, o every level, there is the same amout of work. I the secod case, the amout of work decreases, with the most work beig at level 0. I fact, it decreases geometrically, so by Theorem 4.4 the total work doe is bouded above ad below by a costat times the work doe at the root ode. I the third case, the umber of odes per level is growig at a faster rate tha the problem size is decreasig, ad the level with the largest amout of work is the bottom oe. Agai we have a geometric series, ad so by Theorem 4.4 the total work is bouded above ad below by a costat times the amout of work doe at the last level. If you uderstad these three cases ad the differeces amog them, you ow uderstad the great majority of the recursio trees that arise i algorithms. So to aswer Exercise 5.14, which asks for a geeral BigΘ boud for the solutios to recurreces of the form T () =at (/2) +, weca coclude the followig : 1. if a<2 the T () =Θ(). 2. if a =2the T () =Θ( log ) 3. if a>2 the T () =Θ( log 2 a ) Cases 1 ad 2 follow immediately from our observatios above. We ca verify case 3 as follows. At each level i we have a i odes, each correspodig to a problem of size /2 i.thusat level i the total amout of work is a i (/2 i )=(a/2) i uits. Summig over the log 2 levels, we get (a/2) i. log 2 i=0 The sum is a geometric series, so the sum will be bigθ of the largest term (see Theorem 4.4). Sice a>2, the largest term i this case is clearly the last oe, amely (a/2) log 2, ad applyig rules of expoets ad logarithms, we get that times the largest term is ( ) a log2 = alog log 2 = 2log2 a log2 2 log 2 = log2 a = log 2 a Thus the total work doe is Θ( log 2 a ). Importat Cocepts, Formulas, ad Theorems 1. Divide ad Coquer Algorithm. A divide ad coquer algorithm is oe that solves a problem by dividig it ito problems that are smaller but otherwise of the same type as the origial oe, recursively solves these problems, ad the assembles the solutio of these socalled subproblems ito a solutio of the origial oe. Not all problems ca be solved by such a strategy, but a great may problems of iterest i computer sciece ca.
10 168 CHAPTER 5. RECURSION AND RECURRENCES 2. Mergesort. I mergesort we sort a list of items that have some uderlyig order by dividig the list i half, sortig the first half (by recursively usig mergesort), sortig the secod half (by recursively usig mergesort), ad the mergig the two sorted list. For a list of legth oe mergesort returs the same list. 3. Recursio Tree. A recursio tree diagram for a recurrece of the form T () =at (/b)+g() has three parts. O the left, we keep track of the problem size, i the middle we draw the tree, ad o right we keep track of the work doe. We draw the diagram i levels, each level of the diagram represetig a level of recursio. The tree has a vertex represetig the iitial problem ad oe represetig each subproblem we have to solve. Each oleaf vertex has a childre. The vertices are divided ito levels correspodig to (sub)problems of the same size; to the left of a level of vertices we write the size of the problems the vertices correspod to; to the right of the vertices o a give level we write the total amout of work doe at that level by a algorithm whose work is described by the recurrece, ot icludig the work doe by ay recursive calls. 4. The Base Level of a Recursio Tree. The amout of work doe o the lowest level i a recursio tree is the umber of odes times the value give by the iitial coditio; it is ot determied by attemptig to make a computatio of additioal work doe at the lowest level. 5. Bases for Logarithms. We use log as a alterate otatio for log 2.Afudametal fact about logarithms is that log b = Θ(log 2 ) for ay real umber b>1. 6. Three behaviors of solutios. The solutio to a recurrece of the form T () =at (/2) + behaves i oe of the followig ways: (a) if a<2 the T () =Θ(). (b) if a =2the T () =Θ( log ) (c) if a>2 the T () =Θ( log 2 a ) Problems 1. Draw recursio trees ad fid bigθ bouds o the solutios to the followig recurreces. For all of these, assume that T (1) = 1 ad is a power of the appropriate iteger. (a) T () =8T (/2) + (b) T () =8T (/2) + 3 (c) T () =3T (/2) + (d) T () =T (/4) + 1 (e) T () =3T (/3) Draw recursio trees ad fid fid exact solutios to the followig recurreces. For all of these, assume that T (1) = 1 ad is a power of the appropriate iteger. (a) T () =8T (/2) + (b) T () =8T (/2) + 3 (c) T () =3T (/2) +
11 5.1. GROWTH RATES OF SOLUTIONS TO RECURRENCES 169 (d) T () =T (/4) + 1 (e) T () =3T (/3) Fid the exact solutio to recurrece Show that log b = Θ(log 2 ). 5. Recursio trees will still work, eve if the problems do ot break up geometrically, or eve if the work per level is ot c uits. Draw recursio trees ad ad fid the best bigo bouds you ca for solutios to the followig recurreces. For all of these, assume that T (1) =1. (a) T () =T ( 1) + (b) T () =2T ( 1) + (c) T () =T ( )+1(You may assume has the form =2 2i.) (d) T () =2T (/2) + log (You may assume is a power of 2.) 6. I each case i the previous problem, is the bigo boud you foud a bigθ boud? 7. If S() =as( 1) + g() ad g() <c with 0 c<a,how fast does S() grow (i bigθ terms)? S() =a i S( 1) + i 1 j=0 aj g( j) =a S(0) + 1 j=0 aj g( j) < a S(0) + 1 j=0 aj c j = a S(0) + c 1 ( a ) j j=0 c = a S(0)+Θ( ( ) a c )=Θ(a ) 8. If S() =as( 1) + g() ad g() >c with 0 <a c, how fast does S() grow i bigθ terms? 9. give a recurrece of the form T () =at (/b)+g() with T (1) = c>0 ad g() > 0 for all ad a recurrece of the form S() =as(/b) +g() with S(1) = 0 (ad the same g()), is there ay differece i the bigθ behavior of the solutios to the two recurreces? What does this say about the ifluece of the iitial coditio o the bigθ behavior of such recurreces?
Divide and Conquer, Solving Recurrences, Integer Multiplication Scribe: Juliana Cook (2015), V. Williams Date: April 6, 2016
CS 6, Lecture 3 Divide ad Coquer, Solvig Recurreces, Iteger Multiplicatio Scribe: Juliaa Cook (05, V Williams Date: April 6, 06 Itroductio Today we will cotiue to talk about divide ad coquer, ad go ito
More informationSection IV.5: Recurrence Relations from Algorithms
Sectio IV.5: Recurrece Relatios from Algorithms Give a recursive algorithm with iput size, we wish to fid a Θ (best big O) estimate for its ru time T() either by obtaiig a explicit formula for T() or by
More informationSoving Recurrence Relations
Sovig Recurrece Relatios Part 1. Homogeeous liear 2d degree relatios with costat coefficiets. Cosider the recurrece relatio ( ) T () + at ( 1) + bt ( 2) = 0 This is called a homogeeous liear 2d degree
More informationLecture Notes CMSC 251
We have this messy summatio to solve though First observe that the value remais costat throughout the sum, ad so we ca pull it out frot Also ote that we ca write 3 i / i ad (3/) i T () = log 3 (log ) 1
More informationPage 2 of 14 = T(2) + 2 = [ T(3)+1 ] + 2 Substitute T(3)+1 for T(2) = T(3) + 3 = [ T(4)+1 ] + 3 Substitute T(4)+1 for T(3) = T(4) + 4 After i
Page 1 of 14 Search C455 Chapter 4  Recursio Tree Documet last modified: 02/09/2012 18:42:34 Uses: Use recursio tree to determie a good asymptotic boud o the recurrece T() = Sum the costs withi each level
More informationA Gentle Introduction to Algorithms: Part II
A Getle Itroductio to Algorithms: Part II Cotets of Part I:. Merge: (to merge two sorted lists ito a sigle sorted list.) 2. Bubble Sort 3. Merge Sort: 4. The BigO, BigΘ, BigΩ otatios: asymptotic bouds
More informationHandout: How to calculate time complexity? CSE 101 Winter 2014
Hadout: How to calculate time complexity? CSE 101 Witer 014 Recipe (a) Kow algorithm If you are usig a modied versio of a kow algorithm, you ca piggyback your aalysis o the complexity of the origial algorithm
More informationSECTION 1.5 : SUMMATION NOTATION + WORK WITH SEQUENCES
SECTION 1.5 : SUMMATION NOTATION + WORK WITH SEQUENCES Read Sectio 1.5 (pages 5 9) Overview I Sectio 1.5 we lear to work with summatio otatio ad formulas. We will also itroduce a brief overview of sequeces,
More informationIn nite Sequences. Dr. Philippe B. Laval Kennesaw State University. October 9, 2008
I ite Sequeces Dr. Philippe B. Laval Keesaw State Uiversity October 9, 2008 Abstract This had out is a itroductio to i ite sequeces. mai de itios ad presets some elemetary results. It gives the I ite Sequeces
More informationSolving DivideandConquer Recurrences
Solvig DivideadCoquer Recurreces Victor Adamchik A divideadcoquer algorithm cosists of three steps: dividig a problem ito smaller subproblems solvig (recursively) each subproblem the combiig solutios
More informationDivide and Conquer. Maximum/minimum. Integer Multiplication. CS125 Lecture 4 Fall 2015
CS125 Lecture 4 Fall 2015 Divide ad Coquer We have see oe geeral paradigm for fidig algorithms: the greedy approach. We ow cosider aother geeral paradigm, kow as divide ad coquer. We have already see a
More informationModule 4: Mathematical Induction
Module 4: Mathematical Iductio Theme 1: Priciple of Mathematical Iductio Mathematical iductio is used to prove statemets about atural umbers. As studets may remember, we ca write such a statemet as a predicate
More information.04. This means $1000 is multiplied by 1.02 five times, once for each of the remaining sixmonth
Questio 1: What is a ordiary auity? Let s look at a ordiary auity that is certai ad simple. By this, we mea a auity over a fixed term whose paymet period matches the iterest coversio period. Additioally,
More informationCS 253: Algorithms. Chapter 4. DivideandConquer Recurrences Master Theorem. Credit: Dr. George Bebis
CS 5: Algorithms Chapter 4 DivideadCoquer Recurreces Master Theorem Credit: Dr. George Bebis Recurreces ad Ruig Time Recurreces arise whe a algorithm cotais recursive calls to itself Ruig time is represeted
More informationORDERS OF GROWTH KEITH CONRAD
ORDERS OF GROWTH KEITH CONRAD Itroductio Gaiig a ituitive feel for the relative growth of fuctios is importat if you really wat to uderstad their behavior It also helps you better grasp topics i calculus
More informationThe second difference is the sequence of differences of the first difference sequence, 2
Differece Equatios I differetial equatios, you look for a fuctio that satisfies ad equatio ivolvig derivatives. I differece equatios, istead of a fuctio of a cotiuous variable (such as time), we look for
More informationwhen n = 1, 2, 3, 4, 5, 6, This list represents the amount of dollars you have after n days. Note: The use of is read as and so on.
Geometric eries Before we defie what is meat by a series, we eed to itroduce a related topic, that of sequeces. Formally, a sequece is a fuctio that computes a ordered list. uppose that o day 1, you have
More informationSearching Algorithm Efficiencies
Efficiecy of Liear Search Searchig Algorithm Efficiecies Havig implemeted the liear search algorithm, how would you measure its efficiecy? A useful measure (or metric) should be geeral, applicable to ay
More information8.1 Arithmetic Sequences
MCR3U Uit 8: Sequeces & Series Page 1 of 1 8.1 Arithmetic Sequeces Defiitio: A sequece is a comma separated list of ordered terms that follow a patter. Examples: 1, 2, 3, 4, 5 : a sequece of the first
More informationExample 2 Find the square root of 0. The only square root of 0 is 0 (since 0 is not positive or negative, so those choices don t exist here).
BEGINNING ALGEBRA Roots ad Radicals (revised summer, 00 Olso) Packet to Supplemet the Curret Textbook  Part Review of Square Roots & Irratioals (This portio ca be ay time before Part ad should mostly
More informationSequences II. Chapter 3. 3.1 Convergent Sequences
Chapter 3 Sequeces II 3. Coverget Sequeces Plot a graph of the sequece a ) = 2, 3 2, 4 3, 5 + 4,...,,... To what limit do you thik this sequece teds? What ca you say about the sequece a )? For ǫ = 0.,
More informationLearning outcomes. Algorithms and Data Structures. Time Complexity Analysis. Time Complexity Analysis How fast is the algorithm? Prof. Dr.
Algorithms ad Data Structures Algorithm efficiecy Learig outcomes Able to carry out simple asymptotic aalysisof algorithms Prof. Dr. Qi Xi 2 Time Complexity Aalysis How fast is the algorithm? Code the
More informationAlgorithms and Data Structures DV3. Arne Andersson
Algorithms ad Data Structures DV3 Are Adersso Today s lectures Textbook chapters 14, 5 Iformatiostekologi Itroductio Overview of Algorithmic Mathematics Recurreces Itroductio to Recurreces The Substitutio
More informationRiemann Sums y = f (x)
Riema Sums Recall that we have previously discussed the area problem I its simplest form we ca state it this way: The Area Problem Let f be a cotiuous, oegative fuctio o the closed iterval [a, b] Fid
More information4.1 Sigma Notation and Riemann Sums
0 the itegral. Sigma Notatio ad Riema Sums Oe strategy for calculatig the area of a regio is to cut the regio ito simple shapes, calculate the area of each simple shape, ad the add these smaller areas
More information6 Algorithm analysis
6 Algorithm aalysis Geerally, a algorithm has three cases Best case Average case Worse case. To demostrate, let us cosider the a really simple search algorithm which searches for k i the set A{a 1 a...
More informationTHE ARITHMETIC OF INTEGERS.  multiplication, exponentiation, division, addition, and subtraction
THE ARITHMETIC OF INTEGERS  multiplicatio, expoetiatio, divisio, additio, ad subtractio What to do ad what ot to do. THE INTEGERS Recall that a iteger is oe of the whole umbers, which may be either positive,
More informationFourier Series and the Wave Equation Part 2
Fourier Series ad the Wave Equatio Part There are two big ideas i our work this week. The first is the use of liearity to break complicated problems ito simple pieces. The secod is the use of the symmetries
More informationSequences and Series
CHAPTER 9 Sequeces ad Series 9.. Covergece: Defiitio ad Examples Sequeces The purpose of this chapter is to itroduce a particular way of geeratig algorithms for fidig the values of fuctios defied by their
More informationMath Background: Review & Beyond. Design & Analysis of Algorithms COMP 482 / ELEC 420. Solving for Closed Forms. Obtaining Recurrences
Math Backgroud: Review & Beyod. Asymptotic otatio Desig & Aalysis of Algorithms COMP 48 / ELEC 40 Joh Greier. Math used i asymptotics 3. Recurreces 4. Probabilistic aalysis To do: [CLRS] 4 # T() = O()
More informationCOMP 251 Assignment 2 Solutions
COMP 251 Assigmet 2 Solutios Questio 1 Exercise 8.34 Treat the umbers as 2digit umbers i radix. Each digit rages from 0 to 1. Sort these 2digit umbers ith the RADIXSORT algorithm preseted i Sectio
More informationRepeating Decimals are decimal numbers that have number(s) after the decimal point that repeat in a pattern.
5.5 Fractios ad Decimals Steps for Chagig a Fractio to a Decimal. Simplify the fractio, if possible. 2. Divide the umerator by the deomiator. d d Repeatig Decimals Repeatig Decimals are decimal umbers
More information6.042/18.062J Mathematics for Computer Science. Recurrences
6.04/8.06J Mathematics for Computer Sciece Srii Devadas ad Eric Lehma March 7, 00 Lecture Notes Recurreces Recursio breakig a object dow ito smaller objects of the same type is a major theme i mathematics
More information1 The Binomial Theorem: Another Approach
The Biomial Theorem: Aother Approach Pascal s Triagle I class (ad i our text we saw that, for iteger, the biomial theorem ca be stated (a + b = c a + c a b + c a b + + c ab + c b, where the coefficiets
More informationThe Euler Totient, the Möbius and the Divisor Functions
The Euler Totiet, the Möbius ad the Divisor Fuctios Rosica Dieva July 29, 2005 Mout Holyoke College South Hadley, MA 01075 1 Ackowledgemets This work was supported by the Mout Holyoke College fellowship
More informationA probabilistic proof of a binomial identity
A probabilistic proof of a biomial idetity Joatho Peterso Abstract We give a elemetary probabilistic proof of a biomial idetity. The proof is obtaied by computig the probability of a certai evet i two
More information1.3 Binomial Coefficients
18 CHAPTER 1. COUNTING 1. Biomial Coefficiets I this sectio, we will explore various properties of biomial coefficiets. Pascal s Triagle Table 1 cotais the values of the biomial coefficiets ( ) for 0to
More informationLecture 4: Cauchy sequences, BolzanoWeierstrass, and the Squeeze theorem
Lecture 4: Cauchy sequeces, BolzaoWeierstrass, ad the Squeeze theorem The purpose of this lecture is more modest tha the previous oes. It is to state certai coditios uder which we are guarateed that limits
More informationCHAPTER 3 DIGITAL CODING OF SIGNALS
CHAPTER 3 DIGITAL CODING OF SIGNALS Computers are ofte used to automate the recordig of measuremets. The trasducers ad sigal coditioig circuits produce a voltage sigal that is proportioal to a quatity
More informationCS103X: Discrete Structures Homework 4 Solutions
CS103X: Discrete Structures Homewor 4 Solutios Due February 22, 2008 Exercise 1 10 poits. Silico Valley questios: a How may possible sixfigure salaries i whole dollar amouts are there that cotai at least
More informationChapter Gaussian Elimination
Chapter 04.06 Gaussia Elimiatio After readig this chapter, you should be able to:. solve a set of simultaeous liear equatios usig Naïve Gauss elimiatio,. lear the pitfalls of the Naïve Gauss elimiatio
More information5 Boolean Decision Trees (February 11)
5 Boolea Decisio Trees (February 11) 5.1 Graph Coectivity Suppose we are give a udirected graph G, represeted as a boolea adjacecy matrix = (a ij ), where a ij = 1 if ad oly if vertices i ad j are coected
More information5.4 Amortization. Question 1: How do you find the present value of an annuity? Question 2: How is a loan amortized?
5.4 Amortizatio Questio 1: How do you fid the preset value of a auity? Questio 2: How is a loa amortized? Questio 3: How do you make a amortizatio table? Oe of the most commo fiacial istrumets a perso
More informationCHAPTER 3 THE TIME VALUE OF MONEY
CHAPTER 3 THE TIME VALUE OF MONEY OVERVIEW A dollar i the had today is worth more tha a dollar to be received i the future because, if you had it ow, you could ivest that dollar ad ear iterest. Of all
More informationDetermining the sample size
Determiig the sample size Oe of the most commo questios ay statisticia gets asked is How large a sample size do I eed? Researchers are ofte surprised to fid out that the aswer depeds o a umber of factors
More information3. Greatest Common Divisor  Least Common Multiple
3 Greatest Commo Divisor  Least Commo Multiple Defiitio 31: The greatest commo divisor of two atural umbers a ad b is the largest atural umber c which divides both a ad b We deote the greatest commo gcd
More informationPresent Value Factor To bring one dollar in the future back to present, one uses the Present Value Factor (PVF): Concept 9: Present Value
Cocept 9: Preset Value Is the value of a dollar received today the same as received a year from today? A dollar today is worth more tha a dollar tomorrow because of iflatio, opportuity cost, ad risk Brigig
More informationHere are a couple of warnings to my students who may be here to get a copy of what happened on a day that you missed.
This documet was writte ad copyrighted by Paul Dawkis. Use of this documet ad its olie versio is govered by the Terms ad Coditios of Use located at http://tutorial.math.lamar.edu/terms.asp. The olie versio
More informationProperties of MLE: consistency, asymptotic normality. Fisher information.
Lecture 3 Properties of MLE: cosistecy, asymptotic ormality. Fisher iformatio. I this sectio we will try to uderstad why MLEs are good. Let us recall two facts from probability that we be used ofte throughout
More informationARITHMETIC AND GEOMETRIC PROGRESSIONS
Arithmetic Ad Geometric Progressios Sequeces Ad ARITHMETIC AND GEOMETRIC PROGRESSIONS Successio of umbers of which oe umber is desigated as the first, other as the secod, aother as the third ad so o gives
More informationhp calculators HP 30S Base Conversions Numbers in Different Bases Practice Working with Numbers in Different Bases
Numbers i Differet Bases Practice Workig with Numbers i Differet Bases Numbers i differet bases Our umber system (called HiduArabic) is a decimal system (it s also sometimes referred to as deary system)
More informationI. Chisquared Distributions
1 M 358K Supplemet to Chapter 23: CHISQUARED DISTRIBUTIONS, TDISTRIBUTIONS, AND DEGREES OF FREEDOM To uderstad tdistributios, we first eed to look at aother family of distributios, the chisquared distributios.
More informationA Resource for Freestanding Mathematics Qualifications Working with %
Ca you aswer these questios? A savigs accout gives % iterest per aum.. If 000 is ivested i this accout, how much will be i the accout at the ed of years? A ew car costs 16 000 ad its value falls by 1%
More information{{1}, {2, 4}, {3}} {{1, 3, 4}, {2}} {{1}, {2}, {3, 4}} 5.4 Stirling Numbers
. Stirlig Numbers Whe coutig various types of fuctios from., we quicly discovered that eumeratig the umber of oto fuctios was a difficult problem. For a domai of five elemets ad a rage of four elemets,
More informationBasic Elements of Arithmetic Sequences and Series
MA40S PRECALCULUS UNIT G GEOMETRIC SEQUENCES CLASS NOTES (COMPLETED NO NEED TO COPY NOTES FROM OVERHEAD) Basic Elemets of Arithmetic Sequeces ad Series Objective: To establish basic elemets of arithmetic
More informationData Structures. Outline
Data Structures Solvig Recurreces Tzachi (Isaac) Rose 1 Outlie Recurrece The Substitutio Method The Iteratio Method The Master Method Tzachi (Isaac) Rose 2 1 Recurrece A recurrece is a fuctio defied i
More informationLesson 15 ANOVA (analysis of variance)
Outlie Variability betwee group variability withi group variability total variability Fratio Computatio sums of squares (betwee/withi/total degrees of freedom (betwee/withi/total mea square (betwee/withi
More information3.2 Introduction to Infinite Series
3.2 Itroductio to Ifiite Series May of our ifiite sequeces, for the remaider of the course, will be defied by sums. For example, the sequece S m := 2. () is defied by a sum. Its terms (partial sums) are
More informationMath 475, Problem Set #6: Solutions
Math 475, Problem Set #6: Solutios A (a) For each poit (a, b) with a, b oegative itegers satisfyig ab 8, cout the paths from (0,0) to (a, b) where the legal steps from (i, j) are to (i 2, j), (i, j 2),
More information8.3 POLAR FORM AND DEMOIVRE S THEOREM
SECTION 8. POLAR FORM AND DEMOIVRE S THEOREM 48 8. POLAR FORM AND DEMOIVRE S THEOREM Figure 8.6 (a, b) b r a 0 θ Complex Number: a + bi Rectagular Form: (a, b) Polar Form: (r, θ) At this poit you ca add,
More informationLesson 17 Pearson s Correlation Coefficient
Outlie Measures of Relatioships Pearso s Correlatio Coefficiet (r) types of data scatter plots measure of directio measure of stregth Computatio covariatio of X ad Y uique variatio i X ad Y measurig
More informationCS103A Handout 23 Winter 2002 February 22, 2002 Solving Recurrence Relations
CS3A Hadout 3 Witer 00 February, 00 Solvig Recurrece Relatios Itroductio A wide variety of recurrece problems occur i models. Some of these recurrece relatios ca be solved usig iteratio or some other ad
More informationRunning Time ( 3.1) Analysis of Algorithms. Experimental Studies ( 3.1.1) Limitations of Experiments. Pseudocode ( 3.1.2) Theoretical Analysis
Ruig Time ( 3.) Aalysis of Algorithms Iput Algorithm Output A algorithm is a stepbystep procedure for solvig a problem i a fiite amout of time. Most algorithms trasform iput objects ito output objects.
More information1. C. The formula for the confidence interval for a population mean is: x t, which was
s 1. C. The formula for the cofidece iterval for a populatio mea is: x t, which was based o the sample Mea. So, x is guarateed to be i the iterval you form.. D. Use the rule : pvalue
More informationGeometric Sequences and Series. Geometric Sequences. Definition of Geometric Sequence. such that. a2 4
3330_0903qxd /5/05 :3 AM Page 663 Sectio 93 93 Geometric Sequeces ad Series 663 Geometric Sequeces ad Series What you should lear Recogize, write, ad fid the th terms of geometric sequeces Fid th partial
More informationwhere: T = number of years of cash flow in investment's life n = the year in which the cash flow X n i = IRR = the internal rate of return
EVALUATING ALTERNATIVE CAPITAL INVESTMENT PROGRAMS By Ke D. Duft, Extesio Ecoomist I the March 98 issue of this publicatio we reviewed the procedure by which a capital ivestmet project was assessed. The
More informationLesson 12. Sequences and Series
Retur to List of Lessos Lesso. Sequeces ad Series A ifiite sequece { a, a, a,... a,...} ca be thought of as a list of umbers writte i defiite order ad certai patter. It is usually deoted by { a } =, or
More informationG r a d e. 5 M a t h e M a t i c s. Patterns and relations
G r a d e 5 M a t h e M a t i c s Patters ad relatios Grade 5: Patters ad Relatios (Patters) (5.PR.1) Edurig Uderstadigs: Number patters ad relatioships ca be represeted usig variables. Geeral Outcome:
More informationDefinition. A variable X that takes on values X 1, X 2, X 3,...X k with respective frequencies f 1, f 2, f 3,...f k has mean
1 Social Studies 201 October 13, 2004 Note: The examples i these otes may be differet tha used i class. However, the examples are similar ad the methods used are idetical to what was preseted i class.
More informationChapter 5 An Introduction to Vector Searching and Sorting
Chapter 5 A Itroductio to Vector Searchig ad Sortig Searchig ad sortig are two of the most frequetly performed computig tasks. I this chapter we will examie several elemetary searchig ad sortig algorithms
More informationKey Ideas Section 81: Overview hypothesis testing Hypothesis Hypothesis Test Section 82: Basics of Hypothesis Testing Null Hypothesis
Chapter 8 Key Ideas Hypothesis (Null ad Alterative), Hypothesis Test, Test Statistic, Pvalue Type I Error, Type II Error, Sigificace Level, Power Sectio 81: Overview Cofidece Itervals (Chapter 7) are
More informationAsymptotic Notation, Recurrences: Substitution, Iteration, Master Method. Lecture 2
Asymptotic Notatio, Recurreces: Substitutio, Iteratio, Master Method Lecture 2 Solvig recurreces The aalysis of merge sort from Lecture 1 required us to solve a recurrece. Recurreces are like solvig itegrals,
More information2.3. GEOMETRIC SERIES
6 CHAPTER INFINITE SERIES GEOMETRIC SERIES Oe of the most importat types of ifiite series are geometric series A geometric series is simply the sum of a geometric sequece, Fortuately, geometric series
More informationAsymptotic Growth of Functions
CMPS Itroductio to Aalysis of Algorithms Fall 3 Asymptotic Growth of Fuctios We itroduce several types of asymptotic otatio which are used to compare the performace ad efficiecy of algorithms As we ll
More informationDescriptive statistics deals with the description or simple analysis of population or sample data.
Descriptive statistics Some basic cocepts A populatio is a fiite or ifiite collectio of idividuals or objects. Ofte it is impossible or impractical to get data o all the members of the populatio ad a small
More informationProject Deliverables. CS 361, Lecture 28. Outline. Project Deliverables. Administrative. Project Comments
Project Deliverables CS 361, Lecture 28 Jared Saia Uiversity of New Mexico Each Group should tur i oe group project cosistig of: About 612 pages of text (ca be loger with appedix) 612 figures (please
More informationEngineering 323 Beautiful Homework Set 3 1 of 7 Kuszmar Problem 2.51
Egieerig 33 eautiful Homewor et 3 of 7 Kuszmar roblem.5.5 large departmet store sells sport shirts i three sizes small, medium, ad large, three patters plaid, prit, ad stripe, ad two sleeve legths log
More informationCHAPTER 7: Central Limit Theorem: CLT for Averages (Means)
CHAPTER 7: Cetral Limit Theorem: CLT for Averages (Meas) X = the umber obtaied whe rollig oe six sided die oce. If we roll a six sided die oce, the mea of the probability distributio is X P(X = x) Simulatio:
More informationS. Tanny MAT 344 Spring 1999. be the minimum number of moves required.
S. Tay MAT 344 Sprig 999 Recurrece Relatios Tower of Haoi Let T be the miimum umber of moves required. T 0 = 0, T = 7 Iitial Coditios * T = T + $ T is a sequece (f. o itegers). Solve for T? * is a recurrece,
More informationAQA STATISTICS 1 REVISION NOTES
AQA STATISTICS 1 REVISION NOTES AVERAGES AND MEASURES OF SPREAD www.mathsbox.org.uk Mode : the most commo or most popular data value the oly average that ca be used for qualitative data ot suitable if
More informationMath Discrete Math Combinatorics MULTIPLICATION PRINCIPLE:
Math 355  Discrete Math 4.14.4 Combiatorics Notes MULTIPLICATION PRINCIPLE: If there m ways to do somethig ad ways to do aother thig the there are m ways to do both. I the laguage of set theory: Let
More informationThe geometric series and the ratio test
The geometric series ad the ratio test Today we are goig to develop aother test for covergece based o the iterplay betwee the it compariso test we developed last time ad the geometric series. A ote about
More informationx(x 1)(x 2)... (x k + 1) = [x] k n+m 1
1 Coutig mappigs For every real x ad positive iteger k, let [x] k deote the fallig factorial ad x(x 1)(x 2)... (x k + 1) ( ) x = [x] k k k!, ( ) k = 1. 0 I the sequel, X = {x 1,..., x m }, Y = {y 1,...,
More informationDefinition. Definition. 72 Estimating a Population Proportion. Definition. Definition
7 stimatig a Populatio Proportio I this sectio we preset methods for usig a sample proportio to estimate the value of a populatio proportio. The sample proportio is the best poit estimate of the populatio
More informationHypothesis testing. Null and alternative hypotheses
Hypothesis testig Aother importat use of samplig distributios is to test hypotheses about populatio parameters, e.g. mea, proportio, regressio coefficiets, etc. For example, it is possible to stipulate
More informationRadicals and Fractional Exponents
Radicals ad Roots Radicals ad Fractioal Expoets I math, may problems will ivolve what is called the radical symbol, X is proouced the th root of X, where is or greater, ad X is a positive umber. What it
More informationConfidence Intervals for One Mean with Tolerance Probability
Chapter 421 Cofidece Itervals for Oe Mea with Tolerace Probability Itroductio This procedure calculates the sample size ecessary to achieve a specified distace from the mea to the cofidece limit(s) with
More informationHypothesis Tests Applied to Means
The Samplig Distributio of the Mea Hypothesis Tests Applied to Meas Recall that the samplig distributio of the mea is the distributio of sample meas that would be obtaied from a particular populatio (with
More informationSection 11.3: The Integral Test
Sectio.3: The Itegral Test Most of the series we have looked at have either diverged or have coverged ad we have bee able to fid what they coverge to. I geeral however, the problem is much more difficult
More informationMocks.ie Maths LC HL Further Calculus mocks.ie Page 1
Maths Leavig Cert Higher Level Further Calculus Questio Paper By Cillia Fahy ad Darro Higgis Mocks.ie Maths LC HL Further Calculus mocks.ie Page Further Calculus ad Series, Paper II Q8 Table of Cotets:.
More informationChapter 6: Variance, the law of large numbers and the MonteCarlo method
Chapter 6: Variace, the law of large umbers ad the MoteCarlo method Expected value, variace, ad Chebyshev iequality. If X is a radom variable recall that the expected value of X, E[X] is the average value
More information1 n. n > dt. t < n 1 + n=1
Math 05 otes C. Pomerace The harmoic sum The harmoic sum is the sum of recirocals of the ositive itegers. We kow from calculus that it diverges, this is usually doe by the itegral test. There s a more
More informationarxiv:1012.1336v2 [cs.cc] 8 Dec 2010
Uary SubsetSum is i Logspace arxiv:1012.1336v2 [cs.cc] 8 Dec 2010 1 Itroductio Daiel M. Kae December 9, 2010 I this paper we cosider the Uary SubsetSum problem which is defied as follows: Give itegers
More informationNPTEL STRUCTURAL RELIABILITY
NPTEL Course O STRUCTURAL RELIABILITY Module # 0 Lecture 1 Course Format: Web Istructor: Dr. Aruasis Chakraborty Departmet of Civil Egieerig Idia Istitute of Techology Guwahati 1. Lecture 01: Basic Statistics
More informationMathematical goals. Starting points. Materials required. Time needed
Level A1 of challege: C A1 Mathematical goals Startig poits Materials required Time eeded Iterpretig algebraic expressios To help learers to: traslate betwee words, symbols, tables, ad area represetatios
More informationInfinite Sequences and Series
CHAPTER 4 Ifiite Sequeces ad Series 4.1. Sequeces A sequece is a ifiite ordered list of umbers, for example the sequece of odd positive itegers: 1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29...
More information8.5 Alternating infinite series
65 8.5 Alteratig ifiite series I the previous two sectios we cosidered oly series with positive terms. I this sectio we cosider series with both positive ad egative terms which alterate: positive, egative,
More informationSolving Inequalities
Solvig Iequalities Say Thaks to the Authors Click http://www.ck12.org/saythaks (No sig i required) To access a customizable versio of this book, as well as other iteractive cotet, visit www.ck12.org CK12
More informationA Recursive Formula for Moments of a Binomial Distribution
A Recursive Formula for Momets of a Biomial Distributio Árpád Béyi beyi@mathumassedu, Uiversity of Massachusetts, Amherst, MA 01003 ad Saverio M Maago smmaago@psavymil Naval Postgraduate School, Moterey,
More informationTAYLOR SERIES, POWER SERIES
TAYLOR SERIES, POWER SERIES The followig represets a (icomplete) collectio of thigs that we covered o the subject of Taylor series ad power series. Warig. Be prepared to prove ay of these thigs durig the
More information