What is the purpose of the base case in a recursive function?

Answer and explanation

Correct answer: B. To terminate recursion and prevent infinite stack overflow

  1. Step 1: Define the operational structure of recursive algorithms: recursive step and base case.
  2. Step 2: The base case specifies a terminal condition where the function returns a direct value without further recursive calls, halting recursion and preventing infinite loops and call stack overflow.
Answer
To terminate recursion and prevent infinite stack overflow.
Why not the others: Base cases do not allocate heap memory, accelerate speed, or perform automatic compiler tail-call loop conversion.

Practise more Algorithms and Python Programming.

Free questions with an explanation for every one, and full timed EmSAT Achieve (UAE) mock tests.

What is the purpose of the base case… | EmSAT Achieve (UAE)