πŸ“’ Too many exams? Don’t know which one suits you best? Book Your Free Expert πŸ‘‰ call Now!

  • google app store apple app store
  • βœ–

      Question

      What is 'recursion' in

      programming?
      A Executing the same loop multiple times with different variables Correct Answer Incorrect Answer
      B A function that calls itself directly or indirectly Correct Answer Incorrect Answer
      C Passing a function as a parameter to another function Correct Answer Incorrect Answer
      D Defining multiple functions with the same name but different parameters Correct Answer Incorrect Answer
      E Automatically repeating a failed function call until it succeeds Correct Answer Incorrect Answer

      Solution

      Recursion requires a base case (stopping condition) and a recursive case. Example: factorial(n) = n Γ— factorial(n-1), base case factorial(0) = 1. Without a base case, recursion causes a StackOverflow error. Recursive algorithms include tree traversal, binary search, merge sort, and Fibonacci series. Each recursive call uses stack memory.Deep recursion can be replaced with iteration for memory efficiency.

      Practice Next

      Relevant for Exams:

      ask-question