Recursive Algorithms and Recurrence Equations



Introduction

Initial Conditions

Up and Down Substitution

Closed Form






Overview



Analyzing Performance of Non-Recursive Routines is (relatively) Easy



Analyzing Recursive Routines



Recurrences



Evaluating a Recurrence



Initial Conditions



Substituting Up and Down



Solving the Recurrence: Closed Forms




Solving RE

Forward and Backward Substitution, Initial Conditions




Guess and Check: Forward Substitution



Guess and Check: Backward Substitution



Recurrences Without Initial Conditions



Initial Conditions and Solutions - More Examples




Recurrence Equations for Sample Algorithms




Performance of Recursive Routines



Performance of Factorial



Performance of Factorial, revisited



Performance of Fibonacci



Performance of Recursive Binary Search



Towers of Hanoi



More Example Algorithms and their Recurrence Equations



More Example Algorithms and their Recurrence Equations




Technical Issues and Θ on RHS




Technical Issues



$\Theta(n)$ on the RHS




Solution Techniques




Recurrence Equations - Solution Techniques




Checking Recurrence Closed Forms Using Induction




Check Using Induction: Factorial [SKIP]



Example Using Induction: Binary Search [SKIP]




Master Method





Master Method from Text



Examples using Master Method from Text



General Master Method [Not In Book]



Examples



Text's Master Method vs General MM



Other Solution Techniques





Other Methods for Solving Recurrence Equations



Characteristic Equations





Homogenous Linear Recurrence Equations



Homogenous Linear Recurrence Equation: Example



Homogenous Linear Recurrence Equation: Fibonacci Numbers



Non-homogenous Linear Recurrence Equations



Change of Variable



Recursion Tree - Intuition for Master Method





Recursion Tree



Example Recursion Tree



Example Recursion Tree



Tree Properties



Recursion Tree for $T(n) = aT(\frac{n}{b}) + f(n)$



Summing the Values in the Tree



Fine Points



Evaluating the Complexity of the Sum of the Tree Levels



Formalizing Gives the General Master Method