Recursion
Mohd Ayyoob
([Link] CSA, IISc Banglore)
What is Recursive function?
What is Recursion?
What is Recursion?
Recursion is a technique used in many disciplines, including computer science, linguistics, and logic, to solve
problems by breaking them down into simpler, more manageable parts
What is Recursion?
Recursion is a technique used in many disciplines, including computer science, linguistics, and logic, to solve
problems by breaking them down into simpler, more manageable parts
Eg 1 : Gifting Empty Boxes
What is Recursion?
Recursion is a technique used in many disciplines, including computer science, linguistics, and logic, to solve
problems by breaking them down into simpler, more manageable parts
Eg 2 : Matryoshka Doll
What is Recursion?
Recursion is a technique used in many disciplines, including computer science, linguistics, and logic, to solve
problems by breaking them down into simpler, more manageable parts
Eg 3 : Recursion
Reference : CS106B/Stanford
Reference : CS106B/Stanford
Reference : CS106B/Stanford
GENERAL RECIPE :
recursive():
if (test for simple case) :
// base case
Compute the solution without recursion
else :
// recursive case
Break the problem into subproblems of the same form Call recursive() on
each self-similar subproblem
Re assemble the results of the subproblems