Question: Given the following code int toc(int m, int n) { int x, y; if(m == 0 || n == 0) return (m + n); x
- Given the following code
int toc(int m, int n)
{
int x, y;
if(m == 0 || n == 0) return (m + n);
x = toc(m - 1, n);
y = toc(m, n - 1);
return (x + y);
}
i. What is the value returned if the function toc(2, 3) is called?
ii. Describe the procedure to call toc(2, 3) in recursive tree, or call stack diagram, or plain English
iii. Can function call of toc(m, n) possibly cause stack overflow? If yes, give your reason and example values of m and n which cause the problem.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
