0% found this document useful (0 votes)
40 views4 pages

ISC Recursion Theory Questions

Uploaded by

Shivanshu gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
40 views4 pages

ISC Recursion Theory Questions

Uploaded by

Shivanshu gupta
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ISC Class 12 Recursion Theory Questions

Q1. What is recursion?


Answer: Recursion is a process in which a function calls itself directly or indirectly to solve a
problem. Each recursive call works on a smaller subproblem until a base condition is met, which
stops further calls.

Q2. What is a base condition (or terminating condition) in recursion?


Answer: The base condition is the condition that stops further recursive calls. Without it, recursion
would continue indefinitely, causing a stack overflow error.

Q3. What is the difference between recursion and iteration?


Recursion:
- Function calls itself repeatedly.
- Requires a base condition to terminate.
- Uses function call stack (more memory).
- More elegant and easy for divide-and-conquer problems.

Iteration:
- Uses loops (for, while) repeatedly.
- Requires a test condition to terminate.
- Uses single loop control variable (less memory).
- Faster and more efficient for simple repetition.

Q4. What is the importance of the base condition in recursion?


Answer: It ensures that the recursion stops after a finite number of calls. Without a base condition,
the recursive function would keep calling itself and cause infinite recursion (stack overflow).

Q5. What happens if the base condition is missing in recursion?


Answer: The recursive function will keep calling itself endlessly, leading to a stack overflow error due
to excessive memory use.
Q6. Explain the term 'recursive call'.
Answer: A recursive call is a statement inside a function where the function calls itself with a
modified argument.

Q7. What is meant by 'stack' in recursion?


Answer: The stack is the memory area used to keep track of all the function calls during recursion.
Each recursive call pushes its variables onto the stack, and once the function returns, it pops the top
value.

Q8. What is the difference between direct and indirect recursion?


Answer:
- Direct recursion: Function calls itself directly.
- Indirect recursion: Function calls another function which in turn calls the first function.

Q9. What is the general structure of a recursive function in Java?


Answer:
void func(params) {
if(base condition) return;
else func(modified params); // recursive call
}

Q10. What are the advantages of recursion?


Answer:
1. Makes code shorter and cleaner.
2. Solves problems that are naturally recursive (e.g., factorial, Fibonacci).
3. Reduces complex looping logic.

Q11. What are the disadvantages of recursion?


Answer:
1. More memory usage due to stack calls.
2. Slower execution than iteration.
3. Risk of stack overflow if base condition is not defined.
Q12. Give two real-life examples where recursion is used.
Answer:
1. Calculating factorial of a number.
2. Traversing files and directories in a folder structure.
3. Solving the Tower of Hanoi problem.

Q13. Why is recursion called a 'divide and conquer' method?


Answer: Because it divides a problem into smaller subproblems, solves each recursively, and then
combines the results to solve the original problem.

Q14. Can every recursive function be replaced by iteration?


Answer: Yes, any recursive function can be converted into an iterative one, but the iterative version
may be more complex for certain problems (like tree traversal or backtracking).

Q15. Define tail recursion.


Answer: A recursive function is tail recursive if the recursive call is the last statement executed in the
function.

Q16. What is non-tail recursion?


Answer: When the recursive call is not the last statement in the function (some computation
happens after the recursive call).

Q17. What is meant by 'recursive tree'?


Answer: A recursive tree is a diagram that shows how function calls branch out at each level in
recursion, useful to visualize the flow of recursive calls.

Q18. What is the difference between recursive definition and recursive function?
Answer:
- Recursive definition: A mathematical or logical definition that refers to itself.
- Recursive function: A function in code that implements the recursive definition.

Q19. What is backtracking in recursion?


Answer: Backtracking is a technique where recursion explores all possible paths, and if one path
fails, it backtracks to try another. Commonly used in puzzles and pathfinding problems.
Q20. What is the purpose of the recursive call in a function?
Answer: It helps in breaking down the problem into smaller subproblems until the base condition is
met, gradually solving and returning the result to the original call.

You might also like