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 10 of 18

Q91.
Consider the following code:
Which of the following is the base case for the above recursive code?
#include<stdio.h>
int recursive_sum(int n)
{
      if(n == 0)
        return 0;
      return n + recursive_sum(n - 1);
}
int main()
{
     int n = 5;
     int ans = recursive_sum(n);
     printf("%d",ans);
     return 0;
}

Discuss
Answer: (a).if(n == 0)
Q92.
What is the time complexity of the above recursive implementation used to find the sum of the first n natural numbers?
Discuss
Answer: (b).O(n)
Q93.
Which of the following methods used to find the sum of first n natural numbers has the least time complexity?
Discuss
Answer: (c).Binomial coefficient
Q94.
What is the output of the following code?
#include<stdio.h>
int recursive_sum(int n)
{
      if(n == 0)
        return 0;
      return n + recursive_sum(n - 1);
}
int main()
{
      int n = 5;
      int ans = recursive_sum(n);
      printf("%d",ans);
      return 0;
}
Discuss
Answer: (b).15
Q95.
How many times is the function recursive_sum() called when the following code is executed?
#include<stdio.h>
int recursive_sum(int n)
{
      if(n == 0)
        return 0;
      return n + recursive_sum(n - 1);
}
int main()
{
     int n = 5;
     int ans = recursive_sum(n);
     printf("%d",ans);
     return 0;
}

a.

4

b.

5

c.

6

d.

7

Discuss
Answer: (c).6
Q96.
What is the output of the following code?
#include<stdio.h>
int recursive_sum(int n)
{
      if(n == 0)
        return 0;
      return n + recursive_sum(n - 1);
}
int main()
{
     int n = 0;
     int ans = recursive_sum(n);
     printf("%d",ans);
     return 0;
}
Discuss
Answer: (b).0
Q97.
What is the output of the following code?
#include<stdio.h>
int recursive_sum(int n)
{
      if(n == 0)
        return 0;
      return n + recursive_sum(n - 1);
}
int main()
{
     int n = -4;
     int ans = recursive_sum(n);
     printf("%d",ans);
     return 0;
}
Discuss
Answer: (d).runtime error
Q98.
Which of the following methods can be used to find the sum of digits of a number?
Discuss
Answer: (d).Both recursion and iteration
Q99.
What can be the maximum sum of digits for a 4 digit number?
Discuss
Answer: (c).36
Q100.
What can be the minimum sum of digits for a 4 digit number?
Discuss
Answer: (b).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!