Quiz: Algorithmic Warm Up
Get ready for a short quiz to test the concepts taught in this chapter.
1
Consider the following algorithm to compute the -th Fibonacci number.
def fibonacci(n):
if n <= 1:
return n
else:
print(f'Computing F{n} recursively...')
return X
Which line should replace X
to complete the code above?
A)
fibonacci(n) + fibonacci(n-2)
B)
fibonacci(n-1) + fibonacci(n-2)
C)
fibonacci(n-1)
D)
fibonacci(n) + fibonacci(n-1)
Question 1 of 100 attempted
Level up your interview prep. Join Educative to access 80+ hands-on prep courses.