Quiz on Fibonacci Numbers

Last Updated : 25 Sep, 2023

The Fibonacci series is the sequence where each number is the sum of the previous two numbers of the sequence. The first two numbers of the Fibonacci series are 0 and 1 and are used to generate the Fibonacci series. More on Fibonacci Numbers…

Fibonacci Numbers Quiz

Fibonacci Numbers Quiz


Question 1

What is the Fibonacci sequence?

Cross

A sequence of odd numbers

Cross

A sequence of even numbers

Cross

A sequence of prime numbers

Tick

A sequence of numbers where each number is the sum of the two preceding ones



Question 1-Explanation: 

Fibonacci sequence is one of the most known formulas in number theory. In the Fibonacci sequence, each number in the series is calculated by adding the two numbers before it. Generally, the first two terms of the Fibonacci series are 0 and 1. Fibonacci sequence was known in India hundreds of years before Leonardo Pisano Bigollo know about it. November 23rd is celebrated as Fibonacci Day, as it has the digits “1, 1, 2, 3” which is part of the sequence.

The Fibonacci sequence is as follows: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987, 1597, 2584, 4181, 6765, 10946,…. 

Question 2

Choose the recursive formula for the Fibonacci series.(n>=1)

Cross

F(n) = F(n+1) + F(n+2)

Cross

F(n) = F(n) + F(n+1)

Tick

F(n) = F(n-1) + F(n-2)

Cross

F(n) = F(n-1) – F(n-2)



Question 2-Explanation: 

Formula of Fibonacci Number Fn = Fn-1 + Fn-2

  • Fn is the term number “n”
  • Fn−1 is the previous term (n−1)
  • Fn−2 is the term before that (n−2)

 

Hence (C) is the correct answer.

Question 3

Guess the next value of the Fibonacci sequence: 21, 34, 55, ___, 144.

Tick

89

Cross

63

Cross

83

Cross

43



Question 3-Explanation: 

In the above Fibonacci Series , a= 21, b= 34 so c=a+b = 21 + 34 = 55
Again, a=34, b=55 then c= a+b = 34 + 55 = 89
LikeWise,  a= 55, b=89 then c= 55+89 = 144.

Hence (A) is the correct answer.

Question 4

What is the time complexity of calculating the nth Fibonacci number using dynamic programming?

Tick

O(N)

Cross

O(logN)

Cross

O(2^N)

Cross

O(N^2)



Question 4-Explanation: 

Below is the implementation of the Fibonacci number using the Fibonacci Series:

// C++ program for Fibonacci Series
// using Dynamic Programming
int fib(int n)
{

    // Declare an array to store
    // Fibonacci numbers.
    // 1 extra to handle
    // case, n = 0
    int f[n + 2];
    int i;

    // 0th and 1st number of the
    // series are 0 and 1
    f[0] = 0;
    f[1] = 1;

    for (i = 2; i <= n; i++) {

        // Add the previous 2 numbers
        // in the series and store it
        f[i] = f[i - 1] + f[i - 2];
    }
    return f[n];
}

Here we can see that we are iterating through a loop from i=2 to n. So it will take O(N) time.

Hence (A) is the correct answer.

Question 5

Which of the following algorithms is efficient for calculating Fibonacci numbers, especially for large values of n?

Cross

Brute-force recursion

Cross

Depth-First Search (DFS)

Cross

Sieve of Eratosthenes

Tick

Dynamic programming



Question 5-Explanation: 

Dynamic programming is efficient for calculating Fibonacci numbers, especially for large values of n.

Hence (D) is the correct answer.

Question 6

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];
}
Tick

we have not assigned the first and second value of the list

Cross

we have declared the arry of size n+2

Cross

the loop must be run till (i<n).

Cross

None



Question 6-Explanation: 

we have not assigned the first and second values of the list. So we are going to run the loop for i=2, 

f[2] = f[1] + f[0], but f[1] and f[0] is not initialized.

So the correct code will look like this :

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];
}

Hence (A) is the correct answer.

Question 7

What is the value of F(6) when the value of F(0)= 0 and F(1)=1 in the Fibonacci sequence?

Cross

6

Cross

5

Tick

8

Cross

13



Question 7-Explanation: 

It is clear from the below image that F(6) = 8.

 

Hence (C) is the correct answer.

Question 8

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);
}
Cross

Linear

Cross

Constant

Tick

Exponential

Cross

None



Question 8-Explanation: 

The recursive Fibonacci algorithm has an exponential time complexity of O(2^n). This means that as the input 'n' increases, the number of recursive calls and calculations required grows exponentially. This leads to a significant slowdown for larger values of 'n'.

The reason for the exponential behavior is that the algorithm recalculates the same Fibonacci numbers multiple times, leading to redundant calculations and a high number of function calls.

Hence (C) is the correct answer.

Question 9

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];
}
Cross

O(1)

Cross

O(LogN)

Tick

O(N)

Cross

O(N^2)



Question 9-Explanation: 

In the above code, we are just using an array of size N+2. so here O(N) space is used.

Hence (C) is the correct answer.

Question 10

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);
}
Cross

if(n>=1) return 0;

Cross

if(n<=1) return 0;

Cross

if(n< 1 ) return n;

Tick

if(n<=1) return n; 



Question 10-Explanation: 

The base condition for the Fibonacci algorithm is when N=1 or N=0. and for N=0, the answer will be 0, and for N=1, the answer will be 1.

So, overall it is written like this:

if(n<=1) return n; 

Hence (D) is the correct answer.

There are 10 questions to complete.


Share your thoughts in the comments

Similar Reads