Suppose we wrote a new version of method fib, called newFib. Compare newFib to the original fib shown below:
Public static long newFib(int n)
{
If (n <= 3)
{
Return 1;
}
Else
{
Return newFib(n - 1) + newFib(n - 2) + newFib(n - 3) ;
}
}
Public static long fib(int n)
{
If (n <= 2)
{
Return 1;
}
Else
{
Return fib(n - 1) + fib(n - 2) ;
}
}
For which values of the integer n does newFib(n) always returns a value greater than fib(n) ?
A) any positive n
B) any value of n
C) n >= 3
D) n > 3
Correct Answer:
Verified
Q85: In recursion, the non-recursive case is analogous
Q90: The string "eat" has _ permutations.
A) 2
B)
Q94: Complete the following code snippet, which is
Q96: Consider the following code snippet:
Public static boolean
Q98: In recursion, the recursive call is analogous
Q99: Which of the following statements about palindromes
Q100: Which of the following strings is a
Q102: Backtracking _.
A) starts from the end of
Q105: Consider the following change to the PermutationGenerator
Q107: Which of the following statements about recursion
Unlock this Answer For Free Now!
View this answer and more for free by performing one of the following actions
Scan the QR code to install the App and get 2 free unlocks
Unlock quizzes for free by uploading documents