Question: Given the following code int toc(int m, int n) { int x, y; if(m == 0 || n == 0) return (m + n); x

  1. 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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!