Question
We say that a recursive program is guaranteed to be correct if (1) It is correct for the base case, and (2) The recursive case
We say that a recursive program is guaranteed to be correct if (1) It is correct for the base case, and (2) The recursive case is correct assuming the recursive calls return correct answers. What is the reason for this guarantee of correctness?
A. Infinite recursion
B. Proof by contradiction
C. Mathematical induction
D. Asymptotic notation
Trace the following code. What is mystery(5)?
int mystery(int n): if n <= 2: return 3 return mystery(n-3) + 2*mystery(n-1) - mystery(n-2)
A.
11
B.
21
C.
28
D.
None of these
Which of the following is FALSE about recursion?
A.
All recursive programs can be converted into equivalent iterative programs.
B.
It is more convenient to trace a recursive program in a bottom-up manner, compared to top-down.
C.
The top-down tracing method is closer to the actual order of executation of a recursive program.
D.
Compared to iterative solutions with loops, recursive solutions typically use less memory.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started