Recursion
Parts of recursion: base case, composition, and reduction.
Example
int fact (int n) {
if (n <= 1) {
return 1; // Base case
} else {
return n * fact(n - 1); // Composition (n - 1 is reduction)
}
}
Parts of recursion: base case, composition, and reduction.
int fact (int n) {
if (n <= 1) {
return 1; // Base case
} else {
return n * fact(n - 1); // Composition (n - 1 is reduction)
}
}