Deck 19: Recursion

Full screen (f)
exit full mode
Question
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
Use Space or
up arrow
down arrow
to flip the card.
Question
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
Question
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
Question
A __________ function is one that calls itself

A) dynamic
B) static
C) recursive
D) data validation
E) None of these
Question
When recursion is used on a linked list, it will always display the contents of the list in reverse order.
Question
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
Question
Recursion can be used to:

A) compute factorials
B) find GCD's
C) traverse linked lists
D) All of these
E) None of these
Question
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
Question
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
Question
A recursive function cannot call another function.
Question
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
Question
Any algorithm that can be coded with recursion can also be coded with an iterative structure.
Question
Indirect recursion means that a function calls itself n number of times, then processing of the function starts from the first call.
Question
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
Question
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
Question
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
Question
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
Question
When a recursive function directly calls itself, this is known as direct recursion.
Question
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
Question
Recursive algorithms are less efficient than iterative algorithms.
Question
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.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/21
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 19: Recursion
1
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
2
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
B
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
B
4
A __________ function is one that calls itself

A) dynamic
B) static
C) recursive
D) data validation
E) None of these
Unlock Deck
Unlock for access to all 21 flashcards in this deck.
Unlock Deck
k this deck
5
When recursion is used on a linked list, it will always display the contents of the list in reverse order.
Unlock Deck
Unlock for access to all 21 flashcards in this deck.
Unlock Deck
k this deck
6
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
Unlock Deck
Unlock for access to all 21 flashcards in this deck.
Unlock Deck
k this deck
7
Recursion can be used to:

A) compute factorials
B) find GCD's
C) traverse linked lists
D) All of these
E) None of these
Unlock Deck
Unlock for access to all 21 flashcards in this deck.
Unlock Deck
k this deck
8
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
Unlock Deck
Unlock for access to all 21 flashcards in this deck.
Unlock Deck
k this deck
9
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
Unlock Deck
Unlock for access to all 21 flashcards in this deck.
Unlock Deck
k this deck
10
A recursive function cannot call another function.
Unlock Deck
Unlock for access to all 21 flashcards in this deck.
Unlock Deck
k this deck
11
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
Unlock Deck
Unlock for access to all 21 flashcards in this deck.
Unlock Deck
k this deck
12
Any algorithm that can be coded with recursion can also be coded with an iterative structure.
Unlock Deck
Unlock for access to all 21 flashcards in this deck.
Unlock Deck
k this deck
13
Indirect recursion means that a function calls itself n number of times, then processing of the function starts from the first call.
Unlock Deck
Unlock for access to all 21 flashcards in this deck.
Unlock Deck
k this deck
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
Unlock Deck
Unlock for access to all 21 flashcards in this deck.
Unlock Deck
k this deck
15
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
Unlock Deck
Unlock for access to all 21 flashcards in this deck.
Unlock Deck
k this deck
16
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
Unlock Deck
Unlock for access to all 21 flashcards in this deck.
Unlock Deck
k this deck
17
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
Unlock Deck
Unlock for access to all 21 flashcards in this deck.
Unlock Deck
k this deck
18
When a recursive function directly calls itself, this is known as direct recursion.
Unlock Deck
Unlock for access to all 21 flashcards in this deck.
Unlock Deck
k this deck
19
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
Unlock Deck
Unlock for access to all 21 flashcards in this deck.
Unlock Deck
k this deck
20
Recursive algorithms are less efficient than iterative algorithms.
Unlock Deck
Unlock for access to all 21 flashcards in this deck.
Unlock Deck
k this deck
21
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.
Unlock Deck
Unlock for access to all 21 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 21 flashcards in this deck.