0% found this document useful (0 votes)
6 views4 pages

Understanding Recursion Basics

Recursion is a process where a function calls itself, and a function that does this is termed a recursive function. It includes a base condition to stop recursion and a recursive case to solve smaller problems. An example of recursion is the Tower of Hanoi problem.

Uploaded by

sankarkkdi
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)
6 views4 pages

Understanding Recursion Basics

Recursion is a process where a function calls itself, and a function that does this is termed a recursive function. It includes a base condition to stop recursion and a recursive case to solve smaller problems. An example of recursion is the Tower of Hanoi problem.

Uploaded by

sankarkkdi
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

Recursion:

The process in which a function calls itself directly or indirectly is


called recursion and the corresponding function is called a
recursive function.

return_type function_name(parameters) {
if (base_condition) {
// stop recursion
return value;
} else {
// recursive case
return function_name(smaller_problem);
}
}

Example 1: Tower of Hanoi


You might also like