About 31,400 results
Open links in new tab
  1. Java Recursion: Example - Stack Overflow

    May 29, 2014 · Recursion is pretty expensive in terms of memory allocation and because the computers have a finite amount of memory, if the recursion creates too many boxes, the execution of the program reaches the maximum allowed count of boxes = stack frames and says stack overflow. Be aware that my explanation is a very basic one.

  2. Real-world examples of recursion - Stack Overflow

    Sep 20, 2008 · Recursion is a mathematical abstraction. You can model lots of things using recursion. In that sense, Fibonacci is absolutely real-world, as there are quite some real-world problems that can be modeled this way. If you think that Fibonacci is not real-world, than I would claim that all other examples are abstractions as well, not real-world ...

  3. java - What is recursion - Stack Overflow

    Nov 30, 2012 · Examples of Recursive functions. I have been trying to research recursion in programming as a concept (though I am specifically studying Java) and this is what I got to understand the best: In real life for example, recursion is when we put two mirrors infront of each other and the images produced between them are recursive.

  4. Are there any examples of mutual recursion? - Stack Overflow

    An example might be the minmax algorithm commonly used in game programs such as chess. Starting at the top of the game tree, the goal is to find the maximum value of all the nodes at the level below, whose values are defined as the minimum of the values of the nodes below that, whose values are defines as the maximum of the values below that, whose values ...

  5. recursion - Java recursive Fibonacci sequence - Stack Overflow

    Java Recursion Fibonacci Value. 3. Recursive Fibonacci code. 1. java fibonacci of ANY first two numbers. 0 ...

  6. How to understand the concept of recursion in java?

    Sep 25, 2014 · Recursion is when a method (directly or indirectly) calls itself. The general form of a recursive method is: If a parameter meets a terminating condition, return (usually a result)

  7. java - Recursive Exponent Method - Stack Overflow

    The method must have only one parameter, here's some examples of calling exponent: System.out.println ("The power of 10 in " + n + " is " + exponent(n)); So output should be: The power of 10 in 2 is 1024 OR. The power of 10 in 5 is 9765625

  8. What is recursion and when should I use it? - Stack Overflow

    Don't use recursion for factorials or Fibonacci numbers. One problem with computer-science textbooks is that they present silly examples of recursion. The typical examples are computing a factorial or computing a Fibonacci sequence. Recursion is a powerful tool, and it's really dumb to use it in either of those cases.

  9. Tail Recursion in java - Stack Overflow

    Jul 22, 2012 · This examples includes the important part where the recursion is terminated. Besides of this: As other answers already noted: Since Java does not optimize tail-recursion, there is no point in using it in this language. So you basically end up to optimize your algorithm yourself - by making it iterative.

  10. c++ - What is a good example of recursion other than generating …

    Feb 10, 2011 · Good examples of recursion are often related to cases where underlying data structure or the problem itself is recursive : trees, graphs, algorithms using divide and conquer approach (like many sorts), parser of recursive grammars (like common arithmetic expresions), find strategy for chess-like two players games (for a simple exemple consider ...