Ch 20

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

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

A

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

B

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

C

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

D

A recursive function cannot call another function.

F

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

B

Select all that apply. Which of the following problems can be solved using recursion? a. computing factorials b. finding the greatest common divisor of two numbers c. doing a Binary Search d. multiplying two numbers e. traversing a linked list

A,B,C,E

The following code is an example of a __________ recursive algorithm. int myRecursion(int array[], int first, int last, int val) { int num; if (first > last) return -1; num = (first + last)/2; if (array[num] == val) return num; if (array[num] < val) return myRecursion(array, num + 1, last, val); else return myRecursion(array, first, num - 1, val); } a. Towers of Hanoi b. QuickSort c. binary search d. doubly linked list e. None of these

C

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

C

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

D

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

D

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

D

A problem can be solved with recursion if it can be broken down into successive smaller problems that are the same as the overall problem.

T

Any algorithm that can be coded with recursion can also be coded with an iterative structure.

T

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

B

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

C

If a recursive algorithm does not contain a base case, it a. returns 0 and stops b. returns false and stops c. uses up all available stack memory, causing the program to crash d. reaches the recursive case and stops e. None of these

C

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

D

All mathematical problems are designed to be more efficient using recursive solutions.

F

In a recursive solution, the base case is always the first case to be called.

F

Indirect recursion means that a function calls itself n number of times and then processing of the function starts from the first call.

F

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

F

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

T

Recursive algorithms are less efficient than iterative algorithms.

T

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.

T

To solve a problem recursively, you must identify at least one case in which the problem can be solved without recursion.

T

When a recursive function directly calls itself, this is known as direct recursion.

T


Ensembles d'études connexes

ILTS Elementary Education (305-Content Test)

View Set

Musculoskeletal Impairments: amputations, contractures, hip fxs/replacement, OA/RA, fibromyalgia, osteoporosis, oncology

View Set

COP1220 Quiz 2, COP1220, COP1220 Final

View Set