Bus 392; Chapter 12
T/F: A base case is not necessary for all recursive algorithms.
False
T/F: In many cases it is easier to see how to solve a problem with recursion than with a loop.
False
T/F: Recursion is sometimes required to solve certain types of problems.
False
T/F: Recursive algorithms are always more concise and efficient than iterative algorithms.
False
T/F: There must be only one function involved in any recursive solution.
False
T/F: A problem can normally be solved with recursion if it can be broken down into smaller problems the are identical in structure to the overall problem.
True
T/F: A recursive function must have some way to control the number of times it repeats.
True
T/F: Each time a function is called in a recursive solution, the system incurs overhead that is not incurred with a loop.
True
T/F: If a recursive solution is evident for a particular problem, and if the recursive algorithm does not slow system performance by an intolerable amount, then recursion would probably be a good design choice.
True
T/F: When, in a recursive solution, function A calls function B which, in turn, calls function A, this is known as indirect recursion.
True
A recursive function includes __________ which are not necessary in a loop structure.
c. overhead actions
The process of calling a function requires...
c. several actions to be performed by the computer
A function is called from the main function for the first time and then calls itself seven times. What is the depth of recursion?
d. 7
In a recursive solution, if the problem cannot be solved now, then a recursive function reduces it to a smaller but similar problem and...
d. calls itself to solve the smaller problem.
If, in a recursive solution, function A calls function B which calls function C, this is called __________ recursion.
d. indirect
The base case is the case in which the problem can be solved without...
d. recursion
A recursion in which a function directly calls itself is known as _________ recursion.
direct
Some problems are more __________ solved with recursion than with a loop.
easily
A function is called from the main function and then it calls itself five times. The depth of recursion is __________.
five
Recursive function calls are __________ efficient than loops.
less
A solution using a(n) __________ is usually more evident than a recursive solution.
loop
The majority of repetitive programming tasks are bet done with __________.
loops
Each time a function is called, the system incurs __________ that is not necessary with a loop.
overhead
The base case does not require __________, so it stops the chain of recursive calls.
recursion
All the cases of a recursive solution other than the base case are called the _________ case.
recursive
Usually a problem solved by recursion is reduced by making the value of one or more parameters __________ with each recursive call.
smaller
What defines the depth of recursion?
c. The number of times the function calls itself
Which of the following describes the base case in a recursive solution?
a. A case in which the problem can be solved without recursion
What is the first step to take in order to apply a recursive approach?
a. Identify at least one case in which the problem can be solved without recursion.
Which would be the base case in a recursive solution to the problem of finding the factorial of a number. Recall that the factorial of a non-negative whole number is defined as n! where: If n = 0, then n! = 1 If n > 0, then n! = 1 x 2 x 3 x...x n
a. n = 0
Recursion is...
a. never required to solve a problem
A problem can be solved with recursion if it can be broken down into __________ problems.
a. smaller
If a problem can be solved immediately without recursion, then the recursive function...
a. solves it and returns
What is the second step to take in order to apply recursive approach?
b. Determine a way to use recursion to solve the problem in all circumstances which cannot be solved without recursion.
Recursive functions are __________ iterative algorithms.
b. less efficient than