23.6k views
1 vote
Select all of the following that make this statement true: Recursive solutions _________. a. are always more efficient than iterative solutions b. can lead to stack overflow errors c. are never necessary d. rely on inheritance to work correctly e. are composed of a base case and a recursive relationship f. use constructor chaining

User Yira
by
4.7k points

1 Answer

4 votes

Answer:

b. can lead to stack overflow errors

Step-by-step explanation:

Each recursive call uses some space on the stack. If your recursion is too deep, then it will result in StackOverflow, depending upon the maximum allowed depth in the stack.

When using recursion, you should be very careful and make sure that you provide a base case. A base case in recursion is the condition based on which the recursion ends, and the stack starts to unwind. This is the major reason of recursion causing StackOverflow error. If it doesn't find any base case, it will go into an infinite recursion, which will certainly result in error, as Stack is finite only.

User Darryl Huffman
by
5.2k points