What is the output of examplerecursion


Complete the mcq:

Q1 In the backtracking algorithm, if it is determined that a partial solution would end in a dead end, then the algorithm ____.

terminates

restarts

removes the most recently added part and tries other possibilities

was designed incorrectly

Q2  void decToBin(int num, int base)
{
if(num > 0)
{
decToBin(num/base, base);
cout< }
}

Given the recursive function above, what is the result of decToBin(39, 2)?

10111

10011

100111

110111

Q3  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);
}

Which of the following function calls would result in the value 1 being returned?

func1(0, 1)

func1(1, 0)

func1(2, 0)

func1(1, 2)

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

}

What is the output of func2(2, 3)?

2

3

5

6

Q5  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?

func2(m,n) = func2(n, m) for m >= 0

func2(m,n) = m * n for n >=0

func2(m,n) = m + n for n >=0

func2(m, n) = n * m for n >=0

Q6  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);
}

How many base cases are in the function above?

0

1

2

3

Q7  int func3(int m, int n) {
if (m < n)
return 0;
else
return 1 + func3(m-n, n);

}

What is the value of func3(9, 7), based on the code above?

0

1

2

7

Q8  int rFibNum(int a,int b,int n)
{
if(n==1)
return a;
else if(n==2)
return b;
else
return rFibNum(a,b,n-1) + rFibNum(a,b,n-2);

}

What is the limiting condition of the code above?

n >= 0

a >= 1

b >= 1

n >= 1

Q9  int exampleRecursion (int n)
{
if (n==0)
return 0;
else
return exampleRecursion(n-1) + n*n*n;
}

What does the code above do?

Returns the cube of the number n

Returns the sum of the cubes of the numbers, 0 to n

Returns three times the number n

Returns the next number in a Fibonacci sequence

Q10  int exampleRecursion (int n)
{
if (n==0)
return 0;
else
return exampleRecursion(n-1) + n*n*n;

}

What is the output of exampleRecursion(3) ?

25

32

36

42

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: What is the output of examplerecursion
Reference No:- TGS01937668

Now Priced at $20 (50% Discount)

Recommended (96%)

Rated (4.8/5)