F Chapter 20

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

How many times will the following function call itself, if the value 5 is passed as the argument? void showMessage(int n) { if (n > 0) { cout << "Good day!" << endl; showMessage(n + 1); } }

An infinite number of times

The QuickSort algorithm was developed in 1960 by ________.

C.A.R. Hoare

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

False

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

False

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

False

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

False

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

True

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

True

True/False: Like a loop, a recursive function must have some method to control the number of times it repeats.

True

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

True

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.

True

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

True

The programmer must ensure that a recursive function does not become

an endless loop

A recursive function is designed to terminate when it reaches its ________.

base case

The ________ of recursion is the number of times a recursive function calls itself.

depth

When function A calls function B, which in turn calls function A, this is known as:

indirect recursion

The QuickSort algorithm is used to sort ________.

lists stored in arrays or linear linked lists

A ________ function is one that calls itself

recursive

Recursion can be used to:

traverse linked lists, compute factorials, find GCD's

The QuickSort algorithm works on the basis of

two sublists and a pivot

If a recursive function does not contain a base case, it ________.

uses up all available stack memory, causing the program to crash

The recursive factorial function calculates the factorial of its parameter. Its base case is when the parameter is ________.

zero

How many times will the following function call itself, if the value 5 is passed as the argument? void showMessage(int n) { if (n > 0) { cout << "Good day!" << endl; showMessage(n - 1); } }

5


Ensembles d'études connexes

Iowa Laws, Rules, and Regulation Pertinent to Life Only

View Set

27 - 34 Records & Records, Continued

View Set

McGraw Hill Chapter 2 for health and wellness

View Set

Chapter 13: Nursing Care During Labor and Birth

View Set

Nursehub A&P practice test questions

View Set

Exam 4 study - Cultural Diversity - Chp 5

View Set