Answered! Q43. private int func2(int m, int n) {       if (n == 0)             return 0;       else             return m + func2(m, n-1);…

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

Which of the following statements about the code above is always true?
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

Q44. A method is called directly recursive if it calls another recursive method.
a. true
b. false

Q45. Recursion starts with the base case.
a. true
b. false

Q46. public static int exampleRecursion (int n)
{
if (n==0)
return 0;
else
return exampleRecursion(n-1) + n*n*n;
}

Refer to the code above. What is the output of exampleRecursion(0)?
a. 0
b. 3
c. 9
d. 27

Q47. In the base case, the solution is obtained through a call to a smaller version of the original method.
a. true
b. false

Q48. In reality, if you execute an infinite recursive method on a computer it will execute forever.
a. true
b. false

Q49. Every recursion definition must have zero or more base cases.
a. true
b. false

Q50. private int func1(int m, int n) {
if (m==n || n==1)
return 1;
else
return func1(m-1,n-1) + n*func1(m-1,n);
}

What precondition must exist in order to prevent the code above from infinite recursion?
a. m > = 0 and n >= 0
b. m >= 0 and n >= 1
c. m >= 1 and n >= 0
d. m >= 1 and n >= 1

Expert Answer

 

 

Still stressed from student homework?
Get quality assistance from academic writers!