Discussion
Which of the following cannot be solved by recursion ?
Answer: D
The answer is All of the above can be solved by recursion.
Each is defined in terms of a smaller case of itself:
- Fibonacci: F(n) = F(n-1) + F(n-2), with F(0) = 0 and F(1) = 1.
- Factorial: n! = n × (n-1)!, with 0! = 1.
- Power: xn = x × xn-1, with x0 = 1.
Each has a base case that stops the recursion, so a recursive function solves all three, and none of the first three options is a problem recursion cannot handle.
No comment is present. Be the first to comment.
Loading…
Post your comment
Please log in or register to post a comment.
Examination Categories
- SSC Exams
- Banking Exams
- Teaching Exams
- Civil Services Exams
- Railways Exams
- Engineering Recruitment Exams
- Defence Exams
- State Government Exams
- Police Exams
- Insurance Exams
- Nursing Exams
- Other Government Exams
- NRA CET
- PG Entrance Exams
- Campus Placement
- MBA Entrance Exams
- CUET and UG Entrance
- Judiciary Exams
- Regulatory Body Exams
- Software Development