When implementing a recursive algorithm, what is crucial to avoid infinite recursion?

  • A base case
  • A high stack size
  • A loop
  • Global variables
In a recursive algorithm, it's crucial to have a base case that defines when the recursion should stop. Without a base case, the algorithm will keep calling itself indefinitely, leading to infinite recursion and a stack overflow error.
Add your answer
Loading...

Leave a comment

Your email address will not be published. Required fields are marked *