Docsity

Recurrence Relations: Understanding and Solving - Prof. Eric Torng, Study notes of Computer Science

Toggle sidebar
bg1
Lecture 4
Recurrence Relations
What is a recurrence relation?
You have a set of values V parameterized by one (or more) integers n
V(n) can be defined in terms of V(j) where j < n
There must be at least one base case/boundary value where V(n) is defined absolutely
Example:
V(n) = V(n-1) + V(n-2) + V(n-3)
V(0) = 0
V(1) = 1
V(2) = 2
Two main topics with recurrence relations
1) Identifying an appropriate recurrence relation
When analyzing an algorithm (binary search, Towers of Hanoi) or a combinatorial object
(up-down permutations), you realize a quantity you are interested in can be characterized
using a recurrence relation.
In the long term, this is the crucial analysis step I will focus on throughout this course.
Use small cases to check the correctness of your recurrence relation.
2) Solving recurrence relations (coming up with a closed form)
- Coming up with an exact form for V(n) that does NOT depend on smaller values of V
is the second step in your analysis.
- This is what we will focus on in the short term.
- In real life, you will always have access to books/notes when solving recurrence relations,
so quizzes on this topic will be open book
Methods for solving recurrence relations
0) Using the base case(s) and the recursive case, calculate the quantity for some small values
These can be used to guess the correct solution or partially verify the correctness
of a derived solution.
1) Guess the correct solution and prove by induction
Based on the small values calculated above, you may be able to guess the
correct solution.
You can prove your solution correct using induction.
See example in book
2) More complex solution method focusing on:
- Set up recurrence relations
- Compute homogeneous solution
- Characteristic equation
- Compute the particular solution
- Shortcut for case where the function is bn times a polynomial fct in n
- Use base cases or recurrence relation to solve for constants
3) Other issues
- multiple roots
- changing variables
- Master Theorem
- See handout (see also Example 4.7.13 and problem 4.44 for slightly different version)
- visualization with recursion tree

Partial preview of the text

Download Recurrence Relations: Understanding and Solving - Prof. Eric Torng and more Study notes Computer Science in PDF only on Docsity!

Lecture 4 Recurrence Relations What is a recurrence relation? You have a set of values V parameterized by one (or more) integers n V(n) can be defined in terms of V(j) where j < n There must be at least one base case/boundary value where V(n) is defined absolutely Example: V(n) = V(n-1) + V(n-2) + V(n-3) V(0) = 0 V(1) = 1 V(2) = 2 Two main topics with recurrence relations

  1. Identifying an appropriate recurrence relation When analyzing an algorithm (binary search, Towers of Hanoi) or a combinatorial object (up-down permutations), you realize a quantity you are interested in can be characterized using a recurrence relation. In the long term, this is the crucial analysis step I will focus on throughout this course. Use small cases to check the correctness of your recurrence relation.
  2. Solving recurrence relations (coming up with a closed form)
  • Coming up with an exact form for V(n) that does NOT depend on smaller values of V is the second step in your analysis.
  • This is what we will focus on in the short term.
  • In real life, you will always have access to books/notes when solving recurrence relations, so quizzes on this topic will be open book Methods for solving recurrence relations
  1. Using the base case(s) and the recursive case, calculate the quantity for some small values These can be used to guess the correct solution or partially verify the correctness of a derived solution.
  2. Guess the correct solution and prove by induction Based on the small values calculated above, you may be able to guess the correct solution. You can prove your solution correct using induction. See example in book
  3. More complex solution method focusing on:
  • Set up recurrence relations
  • Compute homogeneous solution
  • Characteristic equation
  • Compute the particular solution
  • Shortcut for case where the function is bn^ times a polynomial fct in n
  • Use base cases or recurrence relation to solve for constants
  1. Other issues
  • multiple roots
  • changing variables
  • Master Theorem
  • See handout (see also Example 4.7.13 and problem 4.44 for slightly different version)
  • visualization with recursion tree