/
pro-recursiveproblemproblem.recurrencearguments.re-nicely.proverecursi pro-recursiveproblemproblem.recurrencearguments.re-nicely.proverecursi

pro-recursiveproblemproblem.recurrencearguments.re-nicely.proverecursi - PDF document

lois-ondreau
lois-ondreau . @lois-ondreau
Follow
367 views
Uploaded On 2015-08-04

pro-recursiveproblemproblem.recurrencearguments.re-nicely.proverecursi - PPT Presentation

Post 1 Post 2 Post 3 problemrulesare 2 Recurrences approachproblemthreeWebelowareLargercorrespondlarger 1 2 3 2 1 3 1 2 3 1 2 3 1 2 1 3 2 1 2 3 1 3 problem ID: 100297

Post Post Post

Share:

Link:

Embed:

Download Presentation from below link

Download Pdf The PPT/PDF document "pro-recursiveproblemproblem.recurrencear..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

pro-recursiveproblemproblem.recurrencearguments.re-nicely.proverecursivecorrectrunningrecurrence Post #1 Post #2 Post #3 problemrulesare 2 Recurrences approachproblemthreeWebelow.areLargercorrespondlarger 1 2 3 ) 2 1 ) 3 1 2 ) 3 1 2 ) 3 1 2 ) 1 3 2 ) 1 2 3 ) 1 3 problemFrenchEdouardtherewerewerewereaccordingrulesAccordingTowercrumble are,sufcientimportantly,“Willbefore 1.1 Finding a Recurrence TowersHanoiproblemcanrecursivelyfromanother.=1 =3theproves  Weapproachrecursive recursively � fromthird � 1 steps. 1 2 . . . n  ) n  1 2 . . . n  � 1  3 Recurrences largestfromrequires 1 2 . . . ) n  n  � 1  n 1 2 . . . n  � 1  the � third � arerequired. 12. . . ) n  n  � 1  1 2 . . . n  requiredferent � +1Werequired T3   2  +1  = 7   2  +1   15  sufcienteffortprobablyburgerscream,over.) 1.2 Towers WePerhaps—ponderedproblem thereherewhy.fromdifferent � remaining � requires � largest � arerequired � 1smaller disks on top. Recurrences argumentrequired � +1recurrencerequiredTowerproblem =1 =2 � +1   2) Werecurrence=3;T=7;T=15;::: 1.3 Guess-and-Verify fromrecurrencerequireexpressionrequiredTowersproblempurchaseburgerscreambefore Therearedifferentrecurrences.correct,proof. n 1  1  2  3  3  7  4  15  5  31  6  63  Tn  n =2 � 1. recurrence,proofwrong.we'rewrong, let's check.) Claim. If: =1  Tn  =2+1  (for n 2) then: Tn  =2 � 1  Recurrences n Proof.proofproposition=2 � 1. 1 (1)true=1=2 � =2 n  � prove=2 n+1  � where  1. =2+1  =2(2 n  � 1)+1  =2 n+1  � 1  recurrencerelation, require 7  � 1=127Weresolveremaining= 2 64  � morebefore 2 Graduate Student Job Prospects (say,thereareInitially,therewerewereareprospectsmoreWorse,increasingprofessorsareincreasingmorerapidly.Eventually,career.problemstopparticular,“AreTAsHereareproblem. • Thereare • Congressforcedretirementretirevoluntarily.trueproblem!)therefore, • year,professorpro-year.professorsare • thereareprofessorsprofessorhired. Recurrences 2.1 Finding a Recurrence Ideally,professorsyear.areprofessorsToproblem, (0) =  0  professors; (1) =  1  professor; (2) =  1  professor; (3) =  2  prof,prof;profbusy,prof (4) =  3  prof,profs;profbusy,profs (5) =  5  profs,profs (6) =  8  profs,profs professorsprofessorshires.professors � hiresprofessors � professorsyear.recurrenceprofessors: (0) =0 (1) =1 )=  � 1) +  � 2) (  2)  recurrence.areintroducedreproduction.appear,requiregreatestarerecurrence, 2.2 Solving the Recurrence recurrencerecurrencelinear.(Well,lecture; X 7 Recurrences recurrence )=  � 1) +  � 2) + : : :  � d)  d = bif(n  � i)  i=1  where; a;: : : aarerecurrencerecurrenceordercoefcients=1recurrence.) now,recurrence;recurrenceslecture.ruleofunfamiliarrecurrence.recurrence,However,reallyrun”;proof.Rather, n )=  HereareintroducedimprovecorrectproofToimprove(0) =0 (1) =1 Verication.recurrence)=  � 1) +  � 2) gives: nn � 1  cx = cx + cx  n � 2  2  + 1  2  x  � x  � 1 =0  1   p 5  x =  2  In the rst step, we divide both sides of the equation by cx n � 2 rearrange This calculation suggests that the connstant c can be anything, but that x must be (1   Evidently,therearerecurrence: 1  � p 5  ! nn  1 +  ! )= )=  22  theoremtruerecurrences. arerecurrence)+  X X X X ! ! X �  8 Recurrences Proof.are d )=  � i)  i=1  d )=  � i)  i=1  Multiplying the rst equation by c, the second by d, and summing gives: dd )+ )= ca � )+ da � i)  i=1 i=1 d = ai cf (n  � )+  � i)  i=1  )+  phenomenon—differentialconsequently,presenttheorem 1  � p 5  ! nn  1 +  ! )=  22  torecurrenceremains(0)=0 (1)=1From 1  � p 5  ! 0  1 +  ! 0  (0) = =0  22  From 1  � p 5  ! 1  1 +  ! 1  (1) = =1  22  Wethere=1 � We'reWerecurrence 1  � p 5  ! nn  1 1 +  ! 1  )=  p52 �p52  Recurrences wrong!areexpressionsquarerootsAmazingly,however,squarerootsexpressionreally=0;:::across 2.3 Job Prospects returnare To  thereareprofessorsshufingobscure 19  years. hardexactly.However,approximateanswer.zero: 1  � p 5  ! nn  1 1 +  ! 1  )=  p52 �p52  n  1 1 +  ! (1)  p52  This is because (1  � 2=0618:::   jj tiny. Fromapproximationin n  1 1 +  ! f(n)   N p52  arewhere: log((1))  log( 1+ 2  p 5 )  = (log professorsincreasingexponentially.=10000 =20YourTAs recurrenceinterestingcorollary. 1 +  ! =  2  Recurrences Ratio”.We n  )= + (1)  p 5  We'veexpressionlargenamely,number.properties 3 General Linear Recurrences recurrencerecurrence.recurrence )=  � 1) +  � 2) + ::: � d)  )=  n recurrence, nn � d  x= a1x  n � 1  + a2x  n � 2  ::: d  x= a1x  d � 1  + a2x  d � 2  ::: � 1x+ ad  Dividing the rst equation by x n � d  recurrence.readoffcoefcientsarecoefcientsrecur-rence. recurrenceareroots • nonrepeatedroot n  recurrence. • repeatedroot nn  ; nr; nr; :::; n  k � 1  r  arerecurrence. Futhermore,Theorem 1 solutions recurrencerootsroots nnn )=  1  )=  2  )=  n  )=  3 r 3  11 Recurrences Thus, every linear combination ar  +  b r  +  cr +  d  nr  f(n)  n 1  n 2  n 3  n 3  is also a solution. remainsappropriately.were(0) =0(1) =1(2) =4 (3) =9 01  02  0 d + 3  03 (0)=0 +  b  0r  0 + ar  r  cr  =  )    11  12  13  13 (1)=1 +  b  +  d 1r  1 + ar  r  cr  =  )   21  22  23  23 (2)=4 +  b  +  d 2r  4 + ar  r  cr  =  )   31  32  33  33 (3)=9 +  b  +  d 3r  9 + ar  r  cr  =  )   All the nasty r i  arerecurrence 3.1 An Example thereforever,reproducesgrow?reverseproblemwhere“reproduce” (0) =0  j  (1) =1frombeforefrombefore � year, � 1) � f(n � together,recurrence )=  � 1) + ( � 1)  � f(n  � 2)) =2 � 1)  � f(n  � 2)  2 � + 1 =0root=1 Therefore,recurrence The characteristic equation is x )= (1) n  (1) n  = c1 + c2n  The boundary conditions imply two linear equations in two unknowns: (0) =0  ) (0) =0 (1) =1  ) (1) =1  Recurrences = 0= 1Therefore,recurrence )=  = 0+(1) = n  thereareprobablyproblemmoreguess-and-verify.recurrenceeasy. 4 Inhomogeneous Recurrences Werecurrences )=  � 1)+ � 1)+::: � d)  recurrences.recurrence )=  � 1)+ � 1)+::: � )+ recurrencere-currence: )=  � 1)+ � 2)+1  recurrencesdifferentdifcult.Wethree 1. resultingrecurrencebefore.(Ignore;c;:::;crecurrence 2. restorerecurrence,Thereareguess-and-verify.wisely. 3. Add the homogeneous and particular solutions together to obtain the general solu-tion. Now use the boundary conditions to determine constants by the usual method of generating and solving a system of linear equations. differentialprobablyfamiliar.arounddifferentialfamiliar. Recurrences 4.1 An Example recurrence (1)=1 )=4 � 1)+3 n  Step 1: Solve the Homogeneous Recurrence recurrence)=4 � 1). The characteristic equation is x  � 4=0 n root=4Therefore,)= Step 2: Find a Particular Solution n recurrence)= 4 � 1)+3there n whererecurrence n d3 n  =4 n � 1  +3=4+3  � 3  Evidently,)= � 3  3 n  = � 3 n+1  is a particular solution. Step 3: Add Solutions and Find Constants We )= n  � 3 n+1  The boundary condition gives the value of the constant c: ) c4 1  � 3 1+1  =1  (1)=1  c =  ) 2  n Therefore,recurrence)=  5 4 � 3 n+1 . Piece of cake! 2 surethat= 2Fromrecurrence,(2)= 4(1)+3 2  = 13From 2 (2)=  5 4 � 3 3  =40 � 27=13 2 Recurrences 4.2 How to Guess a Particular Solution hardestrecurrenceswrong.However,rules • Generally, • )=)=)= 2  +bn +c, etc. • Moregenerally,samedegree,degreehigher,higher,)=6+5)=)= 2  +bn +c. • If g(n)is an exponential, such as 3 n )= n )= n  +c3 n  and then an 2 3 n  +bn3 n  +c3 n , etc. 15 Recurrences Short Guide to Solving Linear Recurrences recurrence )=  � 1) +  � 2) + ::: � )+ |{z} homogeneous part inhomogeneous part (0) = (1) =  1. roots x  n  = a1x  n � 1  + a2x  n � 2  ::: 2. Writeroot n nonrepeatedrootwherelater.root nn 2 nn  cr 1 r; c 2 nr; c 3 nr; :::; c k n  k � 1  r  where 1 ;:::;carelater. rk  3. recurrenceverify.degree,degreehigher,higher,)= )= )=  2 +bn+c. If g(n)is an exponential, such as 3 n )=  n  )=  n  + c3 n  and then an 2 3 n  + bn3 n  + c3 n , etc. 4. Here )=  n  + d( � 1) n  +3+ 1  |{z} homogeneous solution particular solution 5. (1) =2  2=   2 1  + d  ( � 1) 1  + 31+ 1   ) � 2 =2 � d  resulting