Chapter 15: Problem 7
Consider the following recursive function: int mystery (int number) / / Line 1 \(f\) If (number = 0) / / Line 2 return number; else return (mystery (number +1 ) \(-\) number) \(;\) //Line 5\\} a. Identify the base case. b. Identify the general case. c. What valid values can be passed as parameters to the function mystery? d. If mystery (0) is a valid call, what is its value? If not, explain why. e. If mystery (10) is a valid call, what is its value? If not, explain why. f. If mystery (-3) is a valid call, what is its value? If not, explain why.
Short Answer
Step by step solution
Key Concepts
These are the key concepts you need to understand to accurately answer the question.