0% found this document useful (0 votes)
43 views23 pages

Recurrence Relations

The document discusses recurrence relations and how they are used to analyze the time complexity of recursive algorithms like the Fibonacci sequence. Recurrence relations model algorithms in terms of previous terms and can be linear and homogeneous with constant coefficients. Solving these recurrence relations reveals the overall time complexity, such as exponential time complexity for the naive Fibonacci implementation using recursion due to repeated subproblem calls.

Uploaded by

Godawari College
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
43 views23 pages

Recurrence Relations

The document discusses recurrence relations and how they are used to analyze the time complexity of recursive algorithms like the Fibonacci sequence. Recurrence relations model algorithms in terms of previous terms and can be linear and homogeneous with constant coefficients. Solving these recurrence relations reveals the overall time complexity, such as exponential time complexity for the naive Fibonacci implementation using recursion due to repeated subproblem calls.

Uploaded by

Godawari College
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

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

You might also like