Gaddis Python 2e Chapter 13
Download file with the answers
Gaddis Python 2e Chapter 13
1 file(s) 82.41 KB
If you are not a member register here to download this file
Chapter Thirteen
MULTIPLE CHOICE
1. 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
ANS: D
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.
ANS: A
3. 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.
ANS: B
4. 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
ANS: D
5. A problem can be solved with recursion if it can be broken down into _____ problems.
a. smaller
b. one-line
c. manageable
d. modular
ANS: A
6. The base case is a case in which the problem can be solved without _____.
a. loops
b. if
c. objects
d. recursion
ANS: D
7. 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
ANS: B
8. 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
ANS: A
9. 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
ANS: A
10. 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
ANS: C
11. 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
ANS: A
12. 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
ANS: D
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
ANS: C
14. Recursive functions are _____ iterative algorithms.
a. more efficient than
b. less efficient than
c. as efficient as
d. incomparable to
ANS: B
15. A recursive function includes _____ which are not necessary in a loop structure.
a. function calls
b. conditional clauses
c. overhead actions
d. object instances
ANS: C
TRUE/FALSE
1. True/False: A recursive function must have some way to control the number of times it repeats.
ANS: T
2. True/False: In many cases a solution using recursion is more evident than a solution using a loop.
ANS: F
3. True/False: 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.
ANS: T
4. True/False: A base case is not necessary for all recursive algorithms.
ANS: F
5. True/False: There can be several functions involved in the recursion.
ANS: T
6. True/False: Each time a function is called, the system incurs overhead that is not necessary with a loop.
ANS: T
7. True/False: When function A calls function B, which in turn calls function A, it is known as indirect recursion.
ANS: T
8. True/False: A problem can be solved with recursion if it can be broken into smaller problems that are identical in structure to the overall problem.
ANS: T
9. True/False: Recursive algorithms are more concise and efficient than iterative algorithms.
ANS: F
10. True/False: Recursion is required to solve some type of problems.
ANS: F
FILL IN THE BLANK
1. All the cases of the recursive solution other than the base case are called the _______________ case.
ANS: recursive
2. The base case does not require _______________, so it stops the chain of recursive calls.
ANS: recursion
3. Recursive function calls are _______________ efficient than loops.
ANS: less
4. Each time a function is called, the system incurs _______________ that is not necessary with a loop.
ANS: overhead
5. A solution using a(n) _______________ is usually more evident than a recursive solution.
ANS: loop
6. A function is called from the main function and then it calls itself five times. The depth of recursion is _______________.
ANS: five
7. The majority of repetitive programming tasks are best done with _______________.
ANS: loops
8. A recursion in which a function directly calls itself is known as _______________ recursion.
ANS: direct
9. Usually, a problem is reduced by making the value of one or more parameters _______________ with each recursive call.
ANS: smaller
10. Some problems are _______________ solved with recursion than with a loop.
ANS: more easily
Comment ( 1 )
Thanks glad know you and help me answer my difficult question