Chapter 15 Quiz - Recursion

Question Answer
True or False? It is always better to use recursion than iteration in a coding solution. False
True or False? A recursive function must have one and only one base case. False
True or False? In a recursive function, the general case may sometimes reduce the problem to a smaller problem. False
True or False? Any time a function gets called, a copy of that function gets added to the call stack. True
True or False? When a function is added to the call stack, it does not get its own copy of its local variables and parameters - it uses copies created during previous calls to that function. False
This type of recursion occurs when the recursive call is the last line of code in a method: Tail recursion
True or False? When writing a recursive function, you must be careful not to re-do any work that was already done, like in the recursive Fibonacci function. True
A recursive function in which the function calls itself is called what kind of recursion? Direct recursion
True or False? if a function B is called from a function A, function B must finish and be removed from the call stack before function A. True
True or False? When deciding to implement a function recursively or iteratively, you should take into account how easy the code is to understand, with all other things like performance being equal. True