Deck 12: Recursion
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Question
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/35
Play
Full screen (f)
Deck 12: Recursion
1
The process of calling a function requires _____.
A) a long memory access
B) a quick memory access
C) several actions to be performed by the computer
D) one action to be performed by the computer
A) a long memory access
B) a quick memory access
C) several actions to be performed by the computer
D) one action to be performed by the computer
C
2
What is the first step that needs to be taken in order to apply a recursive approach?
A) Identify at least one case in which the problem can be solved without recursion.
B) Determine a way to solve the problem in all other circumstances using recursion.
C) Identify a way to stop the recursion.
D) Determine a way to return to the main function.
A) Identify at least one case in which the problem can be solved without recursion.
B) Determine a way to solve the problem in all other circumstances using recursion.
C) Identify a way to stop the recursion.
D) Determine a way to return to the main function.
A
3
What is referred to as the recursive case?
A) At least one case in which the problem can be solved without recursion
B) A way to solve the problem in all other circumstances using recursion
C) The way to stop the recursion
D) The way to return to the main function
A) At least one case in which the problem can be solved without recursion
B) A way to solve the problem in all other circumstances using recursion
C) The way to stop the recursion
D) The way to return to the main function
B
4
What is referred to as the base case?
A) At least one case in which the problem can be solved without recursion
B) The circumstances to solve the problem using recursion
C) The way to stop the recursion
D) The way to return to the main function
A) At least one case in which the problem can be solved without recursion
B) The circumstances to solve the problem using recursion
C) The way to stop the recursion
D) The way to return to the main function
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
5
A function is called from the main function for the first time. It then calls itself seven times. What is the depth of recursion?
A) Eight
B) Two
C) One
D) Seven
A) Eight
B) Two
C) One
D) Seven
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
6
If a recursive solution is evident for a particular problem, and the recursive algorithm does not slow system performance by an intolerable amount, then recursion would be a good design choice.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
7
In many cases a solution using recursion is more evident than a solution using a loop.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
8
Function A calls function B, which calls function C, which calls function A. This is called _____ recursion.
A) continuous
B) direct
C) three function call
D) indirect
A) continuous
B) direct
C) three function call
D) indirect
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
9
The base case is a case in which the problem can be solved without _____.
A) loops
B) if
C) objects
D) recursion
A) loops
B) if
C) objects
D) recursion
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
10
There can be several functions involved in the recursion.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
11
What is the second step that needs to be taken in order to apply a recursive approach?
A) Identify at least one case in which the problem can be solved without recursion.
B) Determine a way to use recursion in order to solve the problem in all circumstances which cannot be solved without recursion.
C) Identify a way to stop the recursion.
D) Determine a way to return to the main function.
A) Identify at least one case in which the problem can be solved without recursion.
B) Determine a way to use recursion in order to solve the problem in all circumstances which cannot be solved without recursion.
C) Identify a way to stop the recursion.
D) Determine a way to return to the main function.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
12
Recursive functions are _____ iterative algorithms.
A) more efficient than
B) less efficient than
C) as efficient as
D) incomparable to
A) more efficient than
B) less efficient than
C) as efficient as
D) incomparable to
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
13
What defines the depth of recursion?
A) The length of the algorithm
B) The numbers of function calls
C) The number of times the function calls itself
D) The number of times it goes back to the main function
A) The length of the algorithm
B) The numbers of function calls
C) The number of times the function calls itself
D) The number of times it goes back to the main function
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
14
A problem can be solved with recursion if it can be broken down into _____ problems.
A) smaller
B) one-line
C) manageable
D) modular
A) smaller
B) one-line
C) manageable
D) modular
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
15
Recursion is _____.
A) never required to solve a problem
B) required to solve mathematical problems
C) never required to solve string problems
D) required to solve some problems
A) never required to solve a problem
B) required to solve mathematical problems
C) never required to solve string problems
D) required to solve some problems
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
16
A recursive function must have some way to control the number of times it repeats.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
17
A recursive function includes _____ which are not necessary in a loop structure.
A) function calls
B) conditional clauses
C) overhead actions
D) object instances
A) function calls
B) conditional clauses
C) overhead actions
D) object instances
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
18
If the problem can be solved immediately without recursion, then the recursive function _____.
A) solves it and returns
B) Exits
C) returns the result
D) generates a run-time error
A) solves it and returns
B) Exits
C) returns the result
D) generates a run-time error
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
19
A base case is not necessary for all recursive algorithms.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
20
If the problem cannot be solved now, then a recursive function reduces it to a smaller but similar problem and _____.
A) exits
B) returns to the main function
C) returns to the calling function
D) calls itself to solve the smaller problem
A) exits
B) returns to the main function
C) returns to the calling function
D) calls itself to solve the smaller problem
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
21
Recursive function calls are _______________ efficient than loops.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
22
The base case does not require _______________, so it stops the chain of recursive calls.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
23
Some problems are _______________ solved with recursion than with a loop.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
24
Each time a function is called, the system incurs _______________ that is not necessary with a loop.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
25
A solution using a(n) _______________ is usually more evident than a recursive solution.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
26
Recursive algorithms are more concise and efficient than iterative algorithms.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
27
A function is called from the main function and then it calls itself five times. The depth of recursion is _______________.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
28
The majority of repetitive programming tasks are best done with _______________.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
29
Usually, a problem is reduced by making the value of one or more parameters _______________ with each recursive call.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
30
Recursion is required to solve some type of problems.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
31
A problem can be solved with recursion if it can be broken into smaller problems that are identical in structure to the overall problem.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
32
All the cases of the recursive solution other than the base case are called the _______________ case.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
33
A recursion in which a function directly calls itself is known as _______________ recursion.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
34
Each time a function is called, the system incurs overhead that is not necessary with a loop.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck
35
When function A calls function B, which in turn calls function A, it is known as indirect recursion.
Unlock Deck
Unlock for access to all 35 flashcards in this deck.
Unlock Deck
k this deck