Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

int func2(int m, int n) { if( n ==0 ) return0; else return m +func2(m, n-1); } a

ID: 3615810 • Letter: I

Question

int func2(int m, int n)
{
    if( n ==0 )
          return0;
    else
          return m +func2(m, n-1);
}


a) What is the limiting condition of the code above?
a. n >= 0       b. m > n
c. m >= 0      d. n >m

and can you check my answer on this one? I get D? Couldit be B?
b) Which of the following statements about the code above is alwaystrue?
a. func2(m,n) = func2(n,m) for m > = 0
b. func2(m,n) = m * n for n >= 0
c. func2(m,n) = m + n for n >= 0
d. func2(m,n) = n * m for n >= 0

Explanation / Answer


int func2(int m, int n)  
{
    if( n ==0 )
          return0;
    else
          return m +func2(m, n-1);
}


a) What is the limiting condition of the code above?
a. n >= 0     
b. m > n
c. m >= 0     
d. n > m

and can you check my answer on this one? I get D? Couldit be B?
b) Which of the following statements about the code above is alwaystrue?
a. func2(m,n) = func2(n,m) for m > = 0
b. func2(m,n) = m * n for n >= 0
c. func2(m,n) = m + n for n >=0
d. func2(m,n) = n * m for n >= 0

Red lines are the required answer... c is true as the fun2 isreturning m+n not m*n or n*m. int func2(int m, int n)  
{
    if( n ==0 )
          return0;
    else
          return m +func2(m, n-1);
}


a) What is the limiting condition of the code above?
a. n >= 0     
b. m > n
c. m >= 0     
d. n > m

and can you check my answer on this one? I get D? Couldit be B?
b) Which of the following statements about the code above is alwaystrue?
a. func2(m,n) = func2(n,m) for m > = 0
b. func2(m,n) = m * n for n >= 0
c. func2(m,n) = m + n for n >=0
d. func2(m,n) = n * m for n >= 0

Red lines are the required answer... c is true as the fun2 isreturning m+n not m*n or n*m.