adplus-dvertising

Welcome to the Recursion MCQs Page

Dive deep into the fascinating world of Recursion with our comprehensive set of Multiple-Choice Questions (MCQs). This page is dedicated to exploring the fundamental concepts and intricacies of Recursion, a crucial aspect of Data Structures and Algorithms. In this section, you will encounter a diverse range of MCQs that cover various aspects of Recursion, from the basic principles to advanced topics. Each question is thoughtfully crafted to challenge your knowledge and deepen your understanding of this critical subcategory within Data Structures and Algorithms.

frame-decoration

Check out the MCQs below to embark on an enriching journey through Recursion. Test your knowledge, expand your horizons, and solidify your grasp on this vital area of Data Structures and Algorithms.

Note: Each MCQ comes with multiple answer choices. Select the most appropriate option and test your understanding of Recursion. You can click on an option to test your knowledge before viewing the solution for a MCQ. Happy learning!

Recursion MCQs | Page 8 of 18

Q71.
What is the output of the following code?
int fact(int n)
{
      if(n == 0)
        return 1;
      return n * fact(n - 1);
}
int main()
{
      int n = 5;
      int ans = fact(n);
      printf("%d",ans);
      return 0;
}
Discuss
Answer: (b).120
Q72.
Suppose the first fibonnaci number is 0 and the second is 1. What is the sixth fibonnaci number?

a.

5

b.

6

c.

7

d.

8

Discuss
Answer: (a).5
Q73.
Which of the following is not a fibonnaci number?
Discuss
Answer: (d).14
Q74.
Which of the following methods can be used to find the nth fibonnaci number?
Discuss
Answer: (d).All of the mentioned
Q75.
Consider the following iterative implementation to find the nth fibonacci number:
Which of the following lines should be added to complete thebelow code?
int main()
{
    int  n = 10,i;
    if(n == 1)
        printf("0");
    else if(n == 2)
        printf("1");
    else
    {
        int a = 0, b = 1, c;
        for(i = 3; i <= n; i++)
        {
            c = a + b;
            ________;
   ________;
        }
        printf("%d",c);
    }
   return 0;
}
Discuss
Answer: (b).a = b
b = c
Q76.
Which of the following recurrence relations can be used to find the nth fibonacci number?
Discuss
Answer: (d).F(n) = F(n – 1) + F(n – 2)
Q77.
Consider the following recursive implementation to find the nth fibonacci number:
Which of the following lines should be inserted to complete thebelow code?
int fibo(int n)
{
     if(n == 1)
        return 0;
     else if(n == 2)
        return 1;
     return ________;
}
int main()
{
     int n = 5;
     int ans = fibo(n);
     printf("%d",ans);
     return 0;
}
Discuss
Answer: (b).fibo(n – 1) + fibo(n – 2)
Q78.
Consider the following recursive implementation to find the nth fibonnaci number:
Which of the following is the base case?
int fibo(int n)
{
     if(n == 1)
        return 0;
     else if(n == 2)
        return 1;
     return fibo(n - 1) + fibo(n - 2);
}
int main()
{
     int n = 5;
     int ans = fibo(n);
     printf("%d",ans);
     return 0;
}
Discuss
Answer: (d).both if(n == 1) and else if(n == 2)
Q79.
What is the time complexity of the above recursive implementation to find the nth fibonacci number?
Discuss
Answer: (b).O(2n)
Q80.
What is the space complexity of the above recursive implementation to find the nth fibonacci number?
Discuss
Answer: (a).O(1)

Suggested Topics

Are you eager to expand your knowledge beyond Data Structures and Algorithms? We've curated a selection of related categories that you might find intriguing.

Click on the categories below to discover a wealth of MCQs and enrich your understanding of Computer Science. Happy exploring!