About 50 results
Open links in new tab
  1. What is recursion and when should I use it? - Stack Overflow

    Recursion is a tree, with branches and leaves, called parents and children respectively. When you use a recursion algorithm, you more or less consciously are building a tree from the data.

  2. list - Basics of recursion in Python - Stack Overflow

    May 13, 2015 · Tail Call Recursion Once you understand how the above recursion works, you can try to make it a little bit better. Now, to find the actual result, we are depending on the value of the previous …

  3. Newest 'recursion' Questions - Stack Overflow

    Feb 15, 2026 · How does the recursion in generateParenthesis go from backtrack(3, 3) to backtrack(2, 1)? I am working on LeetCode problem 22. Generate Parentheses using a recursive backtracking …

  4. Recursion vs loops - Stack Overflow

    Mar 19, 2009 · Recursion is used to express an algorithm that is naturally recursive in a form that is more easily understandable. A "naturally recursive" algorithm is one where the answer is built from …

  5. algorithm - recursion versus iteration - Stack Overflow

    Feb 23, 2020 · Recursion is usually much slower because all function calls must be stored in a stack to allow the return back to the caller functions. In many cases, memory has to be allocated and copied …

  6. Understanding how recursive functions work - Stack Overflow

    Sep 5, 2014 · Recursion could be implemented by continuation passing style, in which case there is no stack at all. The stack is just one -- particularly efficient, and therefore in common usage -- reification …

  7. performance - Recursion or Iteration? - Stack Overflow

    Jun 24, 2011 · Recursion is more simple (and thus - more fundamental) than any possible definition of an iteration. You can define a Turing-complete system with only a pair of combinators (yes, even a …

  8. Real-world examples of recursion - Stack Overflow

    Sep 20, 2008 · There is no recursion in the real-world. Recursion is a mathematical abstraction. You can model lots of things using recursion. In that sense, Fibonacci is absolutely real-world, as there are …

  9. c++ - How Recursion Works Inside a For Loop - Stack Overflow

    20 For recursion, it's helpful to picture the call stack structure in your mind. If a recursion sits inside a loop, the structure resembles (almost) a N-ary tree. The loop controls horizontally how many …

  10. What are the advantages and disadvantages of recursion?

    Mar 9, 2011 · With respect to using recursion over non-recursive methods in sorting algorithms or, for that matter, any algorithm what are its pros and cons?