Ch 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? Eight Two One Seven
Seven
What defines the depth of recursion? The length of the algorithm The numbers of function calls The number of times the function calls itself The number of times it goes back to the main function
The number of times the function calls itself
Recursion is _____. never required to solve a problem required to solve mathematical problems never required to solve string problems required to solve some problems
never required to solve a problem
A recursive function includes _____ which are not necessary in a loop structure. function calls conditional clauses overhead actions object instances
overhead actions
The base case is a case in which the problem can be solved without _____. loops if objects recursion
recursion
The process of calling a function requires _____. a long memory access a quick memory access several actions to be performed by the computer one action to be performed by the computer
several actions to be performed by the computer
If the problem can be solved immediately without recursion, then the recursive function _____. solves it and returns Exits returns the result generates a run-time error
solves it and returns
What is referred to as the base case? At least one case in which the problem can be solved without recursion The circumstances to solve the problem using recursion The way to stop the recursion The way to return to the main function
At least one case in which the problem can be solved without recursion
What is the second step that needs to be taken in order to apply a recursive approach? Identify at least one case in which the problem can be solved without recursion. Determine a way to use recursion in order to solve the problem in all circumstances which cannot be solved without recursion. Identify a way to stop the recursion. Determine a way to return to the main function.
Determine a way to use recursion in order to solve the problem in all circumstances which cannot be solved without recursion.
If the problem cannot be solved now, then a recursive function reduces it to a smaller but similar problem and _____. exits returns to the main function returns to the calling function calls itself to solve the smaller problem
calls itself to solve the smaller problem