- 2070 Bhadra · 3 marks
Conditions for solving problems recursively
Short answer
Conditions: the problem can be split into smaller problems of the same kind; a base case with a known answer exists; every recursive call moves toward the base case; solutions of subproblems are combined; and enough stack memory is available.
What are the conditions for solving the problems recursively?
A problem can be solved recursively when it satisfies these conditions:
- Smaller sub-problem: the problem can be broken into one or more smaller problems of the same kind (e.g. n! from (n-1)!).
- Base case: there is at least one simple case whose solution is known directly (e.g. 0! = 1) so the recursion can stop.
- Progress toward the base case: each recursive call must reduce the problem so that the base case is eventually reached; otherwise recursion never ends.
- Combining step: the solution of the whole can be built from the solutions of the sub-problems (e.g. n × fact(n-1)).
- Available memory: enough stack space for the depth of recursion.
Example: sum of first n numbers, sum(n) = n + sum(n-1) with sum(0) = 0 satisfies all conditions.
✓ Answer checked by Claude Opus 5.5 (high effort)
Related questions
- Techniques of solving problems; FEM and FDM · Computational Techniques in Civil Engineering, chapter 1