πŸ“’ 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 the primary advantage of using recursion over

      iteration for certain problems (e.g., tree traversals)?
      A Recursion always uses less memory. Correct Answer Incorrect Answer
      B Recursion is always faster. Correct Answer Incorrect Answer
      C Recursion can lead to more elegant and readable solutions that directly mirror the problem's recursive definition. Correct Answer Incorrect Answer
      D Iteration cannot solve problems that recursion can. Correct Answer Incorrect Answer
      E Recursion avoids stack overflow errors. Correct Answer Incorrect Answer

      Solution

      While recursion can sometimes be less efficient (due to stack overhead) or lead to stack overflow for deep recursions, its main advantage is often the clarity and elegance it brings to problems that have an inherent recursive structure (like tree traversals, fractal generation, or certain mathematical definitions). The code can be much more concise and easier to understand.

      Practice Next
      ask-question