πŸŽ“ Computer Science & Engineering Portal

Master Engineering Disciplines with Structured Notes

Comprehensive academic lecture notes, exam-oriented unit summaries, laboratory manuals, and previous year question papers designed strictly for university students.

πŸ“‘

University Syllabi

AKTU & AICTE aligned semester guidelines.

πŸ“

Exam Question Papers

Previous 5 years solved university papers.

πŸ’‘

Lab Manuals & Viva

Practical codes with outputs & interview Qs.

Core Subjects & Units Hub

Click on any specific unit to immediately view its lecture notes below

Viewing All Lectures

Recursion and Recurrence Relation

Recursion  and Recurrence Relation 

Recursion:

Some computer programming languages allow a module or function to call itself. This technique is known as recursion. In recursion, a function Ξ± either calls itself directly or calls a function Ξ² that in turn calls the original function Ξ±. The function Ξ± is called recursive function.

Example:

int function(int value) {
  if(value < 1)
     return;
  function(value - 1);  / / function calling itself
  printf("%d ",value);  
}

A recurrence is an equation or inequality that describes a function in terms of its values on smaller inputs. To solve a Recurrence Relation means to obtain a function defined on the natural numbers that satisfy the recurrence.

3 methods to Solve Recurrence Relation 

  1. Substitution method
  2. Master method
  3. Recursion Tree Method

Substitution: 
It consists of two main steps:

  • Guess the Solution.
  • Use the mathematical induction to find the boundary condition and shows that the guess is correct.

Recursion Tree Method

It is a pictorial representation of an iteration method which is in the form of a tree where at each level nodes are expanded.

 In general, we consider the second term in recurrence as root.

It is useful when the divide & Conquer algorithm is used.

Labels: ,

Discussion & Queries (<$I18NNumComments$>):

<$CommentPager$>
<$I18NAtCommentTimeWithPermalink$>, <$I18NCommentAuthorSaid$>

<$BlogCommentBody$>

<$BlogCommentDeleteIcon$>
<$CommentPager$>