# Data Structure Questions and Answers-Recursion

## Click on any option to know the CORRECT ANSWERS

 Question 1
Recursion is a method in which the solution of a problem depends on .....
 A Larger instances of different problems B Larger instances of the same problem C Smaller instances of the same problem D Smaller instances of different problems
Arab culture Questions answers

Question 1 Explanation:
In recursion, the solution of a problem depends on the solution of smaller instances of the same problem.

 Question 2
Which of the following problems can be solved using recursion?
 A Factorial of a number B Nth fibonacci number C Length of a string D All of the mentioned

Question 2 Explanation:
All of the above mentioned problems can be solved using recursion.

 Question 3
Recursion is similar to which of the following?
 A Switch Case B Loop C If-else D None of the mentioned

Question 3 Explanation:
Recursion is similar to a loop.

 Question 4
In recursion, the condition for which the function will stop calling itself is .....
 A Best case B Worst case C Base case D There is no such condition
English grammar Questions answers

Question 4 Explanation:
For recursion to end at some point, there always has to be a condition for which the function will not call itself. This condition is known as base case.

 Question 5
Consider the following code snippet:

void my....recursive....function() { my....recursive....function(); } int main() { my....recursive....function(); return 0; }

What will happen when the above snippet is executed?

 A The code will be executed successfully and no output will be generated B The code will be executed successfully and random output will be generated C The code will show a compile time error D The code will run for some time and stop when the stack overflows
Computer science Questions answers

Question 5 Explanation:
Every function call is stored in the stack memory. In this case, there is no terminating condition(base case). So, my....recursive....function() will be called continuously till the stack overflows and there is no more space to store the function calls. At this point of time, the program will stop abruptly.

There are 5 questions to complete.