Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Login

Register Now

Welcome to All Test Answers

Chapter 19 Starting out with C++ Recursion


 

Download  file with the answers

Not a member!
Create a FREE account here to get access and download this file with answers


 

Chapter Nineteen

MULTIPLE CHOICE

1. A __________ function is one that calls itself
a. dynamic
b. static
c. recursive
d. data validation
e. None of these

2. Recursion can be used to:
a. compute factorials
b. find GCD’s
c. traverse linked lists
d. All of these
e. None of these

3. The __________ algorithm uses recursion to efficiently sort a list.
a. shell sort
b. quicksort
c. binary sort
d. red/black sort
e. None of these

4. A recursive function that does not have a termination will eventually
a. return 0 and stop
b. return false and stop
c. cause the program to crash
d. reach the Null terminator and stop
e. None of these

5. The __________ of recursion is the number of times a recursive function calls itself.
a. level
b. breadth
c. type
d. depth
e. None of these

6. The QuickSort algorithm works on the basis of
a. three sublists
b. two sublists and a pivot
c. two pivots and a sublist
d. three pivots
e. None of these

7. The programmer must ensure that a recursive function does not become:
a. a static function
b. a prototyped function
c. like an endless loop
d. a dynamic function
e. None of these

8. A recursive function is designed to terminate when it reaches its ________.
a. return statement
b. base case
c. closing curly brace
d. last parameter
e. None of these

9. When function A calls function B, which in turn calls function A, this is known as:
a. direct recursion
b. indirect recursion
c. function swapping
d. perfect recursion
e. None of these

10. The recursive factorial function calculates the factorial of its parameter. Its base case is when the parameter is _______.
a. returned
b. received
c. amortized
d. zero
e. None of these

11. The QuickSort algorithm was developed in 1960 by _________.
a. Bjarne Stroustrup
b. Tony Gaddis
c. C.A.R. Hoare
d. C.M. Turner
e. None of these

12. The QuickSort algorithm is used to sort _____________.
a. lists stored in arrays or linear linked lists
b. tree data structures
c. randomly-ordered files
d. All of these
e. None of these

13. How many times will the following function call itself, if 5 is passed as the argument?

void showMessage(int n)
{
if (n > 0)
{
cout << “Good day!” << endl; showMessage(n – 1); } } a. 1 b. 4 c. 5 d. An infinite number of times ANS: C 14. How many times will the following function call itself, if 5 is passed as the argument? void showMessage(int n) { if (n > 0)
{
cout << “Good day!” << endl;
showMessage(n + 1);
}
}

a. 1
b. 4
c. 5
d. An infinite number of times

TRUE/FALSE

1. True/False: When a recursive function directly calls itself, this is known as direct recursion.

2. True/False: Indirect recursion means that a function calls itself n number of times, then processing of the function starts from the first call.

3. True/False: A recursive function cannot call another function.

4. True/False: Recursive algorithms are less efficient than iterative algorithms.

5. True/False: Any algorithm that can be coded with recursion can also be coded with an iterative structure.

6. True/False: When recursion is used on a linked list, it will always display the contents of the list in reverse order.

7. True/False: The speed and amount of memory available to modern computers diminishes the performance impact of recursion so much that inefficiency is no longer a strong argument against it.

About

Leave a reply

Captcha Click on image to update the captcha .

error: Content is protected !!