Quiz on Fibonacci Numbers (original) (raw)
What is the Fibonacci sequence?
- A sequence of odd numbers
- A sequence of even numbers
- A sequence of prime numbers
- A sequence of numbers where each number is the sum of the two preceding ones
Choose the recursive formula for the Fibonacci series.(n>=1)
Guess the next value of the Fibonacci sequence: 21, 34, 55, ___, 144.
What is the time complexity of calculating the nth Fibonacci number using dynamic programming?
Which of the following algorithms is efficient for calculating Fibonacci numbers, especially for large values of n?
What is wrong with the below code?
C++ `
int fib(int n) { int f[n + 2]; int i; for (i = 2; i <= n; i++) { f[i] = f[i - 1] + f[i - 2]; } return f[n]; }
`
- we have not assigned the first and second value of the list
- we have declared the arry of size n+2
- the loop must be run till (i<n).
What is the value of F(6) when the value of F(0)= 0 and F(1)=1 in the Fibonacci sequence?
What is the output of the below recursive code of the Fibonacci algorithm?
C++ `
int fib(int n) { if (n <= 1) return n;
return fib(n - 1) + fib(n - 2);}
`
What is the space used in the below Fibonacci program?
C++ `
int fib(int n) { int f[n + 2]; int i;
f[0] = 0; f[1] = 1; for (i = 2; i <= n; i++) { f[i] = f[i - 1] + f[i - 2]; } return f[n]; }
`
What should be the base condition for the below recursive code?
C++ `
int fib(int n) { //Base condition
return fib(n - 1) + fib(n - 2); }
`
There are 10 questions to complete.
Take a part in the ongoing discussion