Recurrence Relations
Recurrence Relations
Recurrence Relations
●
Have you ever wondered how to calculate the time complexity
of algorithms like Fibonacci Series where the problem is solved
by dividing it into subproblems
●
This is done by analyzing the Recurrence Relations of the
algorithms.
●
The Fibonacci numbers are the numbers in the following
integer sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ……
●
2
Recurrence Relations
●
The Fibonacci numbers are the numbers in the following
integer sequence: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, ……
●
3
Recurrence Relations
1. // Fibonacci Series using Recursion
●
The Fibonacci numbers 2. #include <stdio.h>
3. int fib(int n)
– Time Complexity: 4. {
Exponential, as every 5. if (n <= 1)
function calls two other 6. return n;
functions. 7. return fib(n - 1) + fib(n - 2);
8. }
9.
10.int main()
11.{
12.int n = 9;
13.printf("%dth Fibonacci Number: %d", n, fib(n));
14.return 0;
15.}
4
Recurrence Relations
●
Linear Recurrence Relations
– A recurrence relation is a mathematical expression that defines a
sequence in terms of its previous terms.
– In the context of algorithmic analysis, it is often used to model the
time complexity of recursive algorithms.
●
5
Recurrence Relations
6
Recurrence Relations
7
Recurrence Relations
8
Recurrence Relations
●
Linear Recurrence Relations
–
9
Recurrence Relations
●
Linear homogeneous recurrence relation with constant
coefficients
10
Recurrence Relations
●
Examples: Linear homogeneous recurrence relation with
constant coefficients
11
Recurrence Relations
12
Recurrence Relations
13
Recurrence Relations
●
Solving linear homogeneous recurrence relation with constant
coefficients
●
14
Recurrence Relations
●
Solving linear homogeneous recurrence relation with constant
coefficients
●
15
Recurrence Relations
16
Recurrence Relations
17
Recurrence Relations
18
Recurrence Relations
19
Recurrence Relations
20
Recurrence Relations
21
Recurrence Relations
22
Introduction to Set, Relations and Functions
●
References:
– Kenneth H. Rosen, Discrete mathematics and its applications,
Seventh Edition McGraw Hill Publication, 2012.
23