Exam 15: Recursion

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

Suppose that function A calls function B, function B calls function C, function C calls function D, and function D calls function A. Function A is then ____________________ recursive.

Free
(Short Answer)
4.8/5
(38)
Correct Answer:
Verified

indirectly

The following is a valid recursive definition to determine the factorial of a non-negative integer. The following is a valid recursive definition to determine the factorial of a non-negative integer.

Free
(True/False)
4.8/5
(40)
Correct Answer:
Verified

True

Consider the following definition of the recursive function mystery. What is the output of the following statement? Cout << mystery(5) << endl; Consider the following definition of the recursive function mystery. What is the output of the following statement? Cout << mystery(5) << endl;

Free
(Multiple Choice)
4.9/5
(41)
Correct Answer:
Verified

A

How many needles are used in the Tower of Hanoi problem?

(Multiple Choice)
4.8/5
(39)

Which of the following solution methods would be the best choice for a mission control system?

(Multiple Choice)
4.7/5
(41)

Consider the following definition of the recursive function mystery. Consider the following definition of the recursive function mystery.   What is the output of the following statement? Cout << mystery(6, 10) << endl; What is the output of the following statement? Cout << mystery(6, 10) << endl;

(Multiple Choice)
4.9/5
(34)

The ____ case is the case for which the solution to an equation is obtained directly.

(Multiple Choice)
4.8/5
(38)

  -Consider the accompanying definition of a recursive function. What is the output of the following statement? cout << puzzle(3, 7) << endl; -Consider the accompanying definition of a recursive function. What is the output of the following statement? cout << puzzle(3, 7) << endl;

(Multiple Choice)
4.8/5
(28)

  -Consider the accompanying definition of a recursive function. What is the output of the following statement? cout << recFunc(8) << endl; -Consider the accompanying definition of a recursive function. What is the output of the following statement? cout << recFunc(8) << endl;

(Multiple Choice)
4.8/5
(38)

Consider the following code. int fact(int num) { if (num == 0) return 1; else return num * fact(num - 1); } The function fact is an example of a(n) ____________________ recursive function.

(Short Answer)
4.8/5
(34)

A definition in which something is defined in terms of a smaller version of itself is called a(n) ____ definition.

(Multiple Choice)
4.8/5
(35)

You can use a recursive algorithm to find the largest element in an array.

(True/False)
4.8/5
(34)

____ control structures use a looping structure, such as while, for, or do...while, to repeat a set of statements.

(Multiple Choice)
4.7/5
(36)

The following is an example of a recursive function. The following is an example of a recursive function.

(True/False)
4.8/5
(43)

Every call to a recursive function requires the system to allocate memory for the local variables and formal parameters.

(True/False)
4.8/5
(39)

To design a recursive function, you must determine the limiting conditions.

(True/False)
4.9/5
(35)

The ____________________ Fibonacci number in a sequence is the sum of the second and third Fibonacci numbers.

(Short Answer)
4.8/5
(35)

Which of the following function headings can be used for a recursive definition of a function to calculate the nth Fibonacci number?

(Multiple Choice)
4.8/5
(43)

Recursive algorithms are implemented using ____________________ functions.

(Short Answer)
4.8/5
(45)

  -Consider the accompanying definition of the recursive function mystery. Given the declaration: int alpha[5] = {1, 4, 5, 8, 9}; What is the output of the following statement? Cout << mystery(alpha, 0, 4) << endl; -Consider the accompanying definition of the recursive function mystery. Given the declaration: int alpha[5] = {1, 4, 5, 8, 9}; What is the output of the following statement? Cout << mystery(alpha, 0, 4) << endl;

(Multiple Choice)
4.7/5
(36)
Showing 1 - 20 of 41
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)