Algorithm CH4 Recurrences
Algorithm CH4 Recurrences
A recurrence is a function is defined in terms of
- one or more base cases, and
- itself, with smaller arguments
Ex.
Substitution method
![](https://raw.githubusercontent.com/z-hwa/webHomeImage/main/image/20240422175055.png)
![](https://raw.githubusercontent.com/z-hwa/webHomeImage/main/image/20240422175129.png)
![](https://raw.githubusercontent.com/z-hwa/webHomeImage/main/image/20240422175147.png)
- T(n) is always constant for any constant n.
- Since we are ultimately interested in asymptotic solution to a recurrence, it will always be possible to choose base cases that work
- When we want an asymptotic solution to a recurrence, we don’t worry about the base cases in our proofs.
- When we want an exact solution, then we have to deal with base cases.
For the substitution method:
- Name the constant in the additive term
- Show the upper (O) and lower (Ω) bounds separately. Might need to use different constants for each notation
substract off a lower-order term may help
waring
![](https://raw.githubusercontent.com/z-hwa/webHomeImage/main/image/20240422175506.png)
Recurrence trees
Goal of the recursion-tree method
- a good guess for the substitution method
- a direct proof of a solution to a recurrence (provided by carefully drawing a recursion tree)
![](https://raw.githubusercontent.com/z-hwa/webHomeImage/main/image/20240422175729.png)
![](https://raw.githubusercontent.com/z-hwa/webHomeImage/main/image/20240422175744.png)
![](https://raw.githubusercontent.com/z-hwa/webHomeImage/main/image/20240422175906.png)
diff. depth
![](https://raw.githubusercontent.com/z-hwa/webHomeImage/main/image/20240423051117.png)
![](https://raw.githubusercontent.com/z-hwa/webHomeImage/main/image/20240423051349.png)
master method
![](https://raw.githubusercontent.com/z-hwa/webHomeImage/main/image/20240423051508.png)
![](https://raw.githubusercontent.com/z-hwa/webHomeImage/main/image/20240423051859.png)
![](https://raw.githubusercontent.com/z-hwa/webHomeImage/main/image/20240423052312.png)
for regularity condition
Algorithm CH4 Recurrences
https://z-hwa.github.io/webHome/[object Object]/2024/04/30/Algorithm/Algorithm-CH4-Recurrences/