Exam 15: Recursion

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

In the Tower of Hanoi recursive program,if needle 1 contains three disks,then the number of moves required to move all three disks from needle 1 to needle 3 is 8.

Free
(True/False)
4.9/5
(75)
Correct Answer:
Verified

False

With recursion,the base case must eventually be reduced to a general case.

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

False

int mystery(int list[ ], int first, int last) { \quad if (first == last) \quad\quad return list[first]; \quad else \quad\quad return list[first] + mystery(list, first + 1, last); } -Consider the accompanying definition of the recursive function mystery.Given the declaration: int beta[10] = {2,5,8,9,13,15,18,20,23,25}; What is the output of the following statement? Cout << mystery(beta,4,7)<< endl;

Free
(Multiple Choice)
4.8/5
(96)
Correct Answer:
Verified

D

In the Tower of Hanoi problem,if needle 1 contains three disks,then the number of moves required to move all three disks from needle 1 to needle 3 is ____________________.

(Short Answer)
4.8/5
(78)

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

(True/False)
4.9/5
(74)

int recFunc(int num) { \quad if (num >= 10) \quad\quad return 10; \quad else \quad\quad return num * recFunc(num + 1); } -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
(82)

  -Consider the accompanying definition of a recursive function.Which of the statements represent the general case? -Consider the accompanying definition of a recursive function.Which of the statements represent the general case?

(Multiple Choice)
4.9/5
(84)

A(n)____________________ control structure is used to control the repeated calls in recursion.

(Short Answer)
4.7/5
(78)

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
(79)

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

(Multiple Choice)
4.9/5
(78)

Consider the following definition of the recursive function mystery. int mystery(int first,int last) { if (first > last) \quad Return 0; else if (first == last) \quad Return first; else \quad return first + mystery(first + 1,last - 1); } What is the output of the following statement? cout << mystery(6,10)<< endl;

(Multiple Choice)
4.8/5
(74)

Consider the following recursive definition,where n is a positive integer. F(1)= 3 F(n)= F(n - 1)+ 1 if n > 1 The value of F(3)is ____________________.

(Short Answer)
4.9/5
(68)

The following is a valid recursive definition to determine the factorial of a non-negative integer. 0! = 1 1! = 1 n! = n * (n - 1)! if n > 0

(True/False)
5.0/5
(80)

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

(Multiple Choice)
4.8/5
(86)

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

(True/False)
4.9/5
(93)

Recursive algorithms are implemented using ____________________ functions.

(Short Answer)
4.9/5
(70)

Let x be an integer.We call the ____________________ of x after division by 2 the rightmost bit of x.

(Short Answer)
4.8/5
(76)

If a function A calls function B and function B calls function A,then function A is ____________________ recursive.

(Short Answer)
4.7/5
(91)

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
(79)

int foo(int n) //Line 1 { //Line 2 if (n == 0) //Line 3 return 0; //Line 4 else //Line 5 return n + foo(n - 1); //Line 6 } //Line 7 -Consider the accompanying definition of a recursive function.Which of the statements represents the base case?

(Multiple Choice)
4.8/5
(68)
Showing 1 - 20 of 50
close modal

Filters

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