Lecture 9: Recurrence Relations
Total Page:16
File Type:pdf, Size:1020Kb
Lecture 9: Recurrence Relations Matthew Fricke Definition Examples Guess and Check Lecture 9: Recurrence Relations Binary Search Characteristic Equation Matthew Fricke Method The Fibonacci Sequence Golden Ratio July 15, 2013 Gambler's Ruin Lecture 9: Recurrence Relations This Lecture Matthew Fricke Definition 1 Definition Examples Guess and 2 Examples Check Binary Search 3 Guess and Check Characteristic Equation Method 4 Binary Search The Fibonacci Sequence Golden Ratio 5 Characteristic Equation Method Gambler's Ruin 6 The Fibonacci Sequence 7 Golden Ratio 8 Gambler's Ruin • Recurrence relations are closely tied to differential equations because they are both self referential. • A differential equation relates a function to its own derivative. • The discrete version of a differential equation is a difference equation. • Sometimes people call recurrence relations difference equations but really difference equations are just a type of recurrence relation. • Some of the techniques for solving recurrence relations are almost the same as those used to solve differential equations. Lecture 9: Recurrence Relations What are Recurrence Relations? Matthew Fricke • A recurrence relation is an equation that defines a value in Definition a sequence using previous values in the sequence. Examples Guess and Check Binary Search Characteristic Equation Method The Fibonacci Sequence Golden Ratio Gambler's Ruin • A differential equation relates a function to its own derivative. • The discrete version of a differential equation is a difference equation. • Sometimes people call recurrence relations difference equations but really difference equations are just a type of recurrence relation. • Some of the techniques for solving recurrence relations are almost the same as those used to solve differential equations. Lecture 9: Recurrence Relations What are Recurrence Relations? Matthew Fricke • A recurrence relation is an equation that defines a value in Definition a sequence using previous values in the sequence. Examples Guess and • Recurrence relations are closely tied to differential Check equations because they are both self referential. Binary Search Characteristic Equation Method The Fibonacci Sequence Golden Ratio Gambler's Ruin • The discrete version of a differential equation is a difference equation. • Sometimes people call recurrence relations difference equations but really difference equations are just a type of recurrence relation. • Some of the techniques for solving recurrence relations are almost the same as those used to solve differential equations. Lecture 9: Recurrence Relations What are Recurrence Relations? Matthew Fricke • A recurrence relation is an equation that defines a value in Definition a sequence using previous values in the sequence. Examples Guess and • Recurrence relations are closely tied to differential Check equations because they are both self referential. Binary Search Characteristic • A differential equation relates a function to its own Equation Method derivative. The Fibonacci Sequence Golden Ratio Gambler's Ruin • Sometimes people call recurrence relations difference equations but really difference equations are just a type of recurrence relation. • Some of the techniques for solving recurrence relations are almost the same as those used to solve differential equations. Lecture 9: Recurrence Relations What are Recurrence Relations? Matthew Fricke • A recurrence relation is an equation that defines a value in Definition a sequence using previous values in the sequence. Examples Guess and • Recurrence relations are closely tied to differential Check equations because they are both self referential. Binary Search Characteristic • A differential equation relates a function to its own Equation Method derivative. The Fibonacci • The discrete version of a differential equation is a Sequence difference equation. Golden Ratio Gambler's Ruin • Some of the techniques for solving recurrence relations are almost the same as those used to solve differential equations. Lecture 9: Recurrence Relations What are Recurrence Relations? Matthew Fricke • A recurrence relation is an equation that defines a value in Definition a sequence using previous values in the sequence. Examples Guess and • Recurrence relations are closely tied to differential Check equations because they are both self referential. Binary Search Characteristic • A differential equation relates a function to its own Equation Method derivative. The Fibonacci • The discrete version of a differential equation is a Sequence difference equation. Golden Ratio Gambler's • Sometimes people call recurrence relations difference Ruin equations but really difference equations are just a type of recurrence relation. Lecture 9: Recurrence Relations What are Recurrence Relations? Matthew Fricke • A recurrence relation is an equation that defines a value in Definition a sequence using previous values in the sequence. Examples Guess and • Recurrence relations are closely tied to differential Check equations because they are both self referential. Binary Search Characteristic • A differential equation relates a function to its own Equation Method derivative. The Fibonacci • The discrete version of a differential equation is a Sequence difference equation. Golden Ratio Gambler's • Sometimes people call recurrence relations difference Ruin equations but really difference equations are just a type of recurrence relation. • Some of the techniques for solving recurrence relations are almost the same as those used to solve differential equations. Lecture 9: Recurrence Relations Examples of Recursion Relations Matthew Fricke Definition Examples Towers of Hanoi T0 = 0 Guess and Check Tn = 2Tn−1 + 1 Binary Search Characteristic Equation Fibonacci Sequence F0 = 0 Method F = 1 The Fibonacci 1 Sequence Fn = Fn−1 + Fn−2 Golden Ratio Gambler's Ruin Compound Interest Stirling Numbers • We solved the problem by figuring out a general statement characterizing the amount of work needed to move one disk from one peg to another: 2(n − 1) + 1 where n is the number of disks. • Then we wrote out the sequence values for T0; T1; T2; T3; T4 ::: = 0; 1; 3; 7; 15 ::: • Guessed that the formula was 2n − 1 • ... and proved it with mathematical induction. Lecture 9: Recurrence Relations Towers of Hanoi Matthew Fricke Definition Examples • Recall that the recurrence Tn represents the amount of Guess and Check work needed to solve the problem. Binary Search Characteristic Equation Method The Fibonacci Sequence Golden Ratio Gambler's Ruin • Then we wrote out the sequence values for T0; T1; T2; T3; T4 ::: = 0; 1; 3; 7; 15 ::: • Guessed that the formula was 2n − 1 • ... and proved it with mathematical induction. Lecture 9: Recurrence Relations Towers of Hanoi Matthew Fricke Definition Examples • Recall that the recurrence Tn represents the amount of Guess and Check work needed to solve the problem. Binary Search • We solved the problem by figuring out a general statement Characteristic Equation characterizing the amount of work needed to move one Method disk from one peg to another: 2(n − 1) + 1 where n is the The Fibonacci Sequence number of disks. Golden Ratio Gambler's Ruin • Guessed that the formula was 2n − 1 • ... and proved it with mathematical induction. Lecture 9: Recurrence Relations Towers of Hanoi Matthew Fricke Definition Examples • Recall that the recurrence Tn represents the amount of Guess and Check work needed to solve the problem. Binary Search • We solved the problem by figuring out a general statement Characteristic Equation characterizing the amount of work needed to move one Method disk from one peg to another: 2(n − 1) + 1 where n is the The Fibonacci Sequence number of disks. Golden Ratio • Then we wrote out the sequence values for Gambler's T ; T ; T ; T ; T ::: = 0; 1; 3; 7; 15 ::: Ruin 0 1 2 3 4 • ... and proved it with mathematical induction. Lecture 9: Recurrence Relations Towers of Hanoi Matthew Fricke Definition Examples • Recall that the recurrence Tn represents the amount of Guess and Check work needed to solve the problem. Binary Search • We solved the problem by figuring out a general statement Characteristic Equation characterizing the amount of work needed to move one Method disk from one peg to another: 2(n − 1) + 1 where n is the The Fibonacci Sequence number of disks. Golden Ratio • Then we wrote out the sequence values for Gambler's T ; T ; T ; T ; T ::: = 0; 1; 3; 7; 15 ::: Ruin 0 1 2 3 4 • Guessed that the formula was 2n − 1 Lecture 9: Recurrence Relations Towers of Hanoi Matthew Fricke Definition Examples • Recall that the recurrence Tn represents the amount of Guess and Check work needed to solve the problem. Binary Search • We solved the problem by figuring out a general statement Characteristic Equation characterizing the amount of work needed to move one Method disk from one peg to another: 2(n − 1) + 1 where n is the The Fibonacci Sequence number of disks. Golden Ratio • Then we wrote out the sequence values for Gambler's T ; T ; T ; T ; T ::: = 0; 1; 3; 7; 15 ::: Ruin 0 1 2 3 4 • Guessed that the formula was 2n − 1 • ... and proved it with mathematical induction. • then analyse the amount of work needed to search using recurrence relations. • Given a sorted array of integers how might we determine if a particular integer is in the array? Lecture 9: Recurrence Relations Binary Search Example Matthew Fricke Definition Examples Guess and Check Binary Search • We are going to come up with an algorithm to solve a Characteristic search problem. Equation Method The Fibonacci Sequence Golden Ratio Gambler's Ruin • Given a sorted