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

Q61.
Which of the following methods can be used to find the factorial of a number?
Discuss
Answer: (d).All of the mentioned
Q62.
Which of the following recursive formula can be used to find the factorial of a number?
Discuss
Answer: (c).fact(n) = n * fact(n-1)
Q63.
Consider the following iterative implementation to find the factorial of a number:
Which of the following lines should be inserted to complete thebelow code?
int main()
{
    int n = 6, i;
    int fact = 1;
    for(i=1;i<=n;i++)
      _________;
    printf("%d",fact);
    return 0;
}
Discuss
Answer: (b).fact = fact * i
Q64.
Consider the following recursive implementation to find the factorial of a number:
Which of the following lines should be inserted to complete thebelow code?
int fact(int n)
{
     if(_________)
        return 1;
     return n * fact(n - 1);
}
int main()
{
      int n = 5;
      int ans = fact(n);
      printf("%d",ans);
      return 0;
}
Discuss
Answer: (c).n == 0
Q65.
What is the time complexity of the above recursive implementation to find the factorial of a number?
Discuss
Answer: (b).O(n)
Q66.
What is the space complexity of the above recursive implementation to find the factorial of a number?
Discuss
Answer: (a).O(1)
Q67.
Consider the following recursive implementation to find the factorial of a number:
Which of the following lines is the base case?
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: (c).if(n == 0)
Q68.
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 = 0;
      int ans = fact(n);
      printf("%d",ans);
      return 0;
}

a.

0

b.

1

c.

2

d.

3

Discuss
Answer: (b).1
Q69.
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 = 1;
      int ans = fact(n);
      printf("%d",ans);
      return 0;
}

a.

0

b.

1

c.

2

d.

3

Discuss
Answer: (b).1
Q70.
How many times will the function fact() be called when the following code is executed?
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;
}

a.

4

b.

5

c.

6

d.

7

Discuss
Answer: (c).6

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!