Chapter
Recursion
From ComputerScienceOne by Dr Chris Bourke
Concepts
- How is recursion implemented in Java?
"Java supports recursion with no special syntax necessary. However, as an object-oriented language, recursion is generally expensive and iterative or other non-recursive solutions are generally prefer
- How can a recursive method sum the elements of an array?
"As another example that actually does something useful, consider the following recursive summation method that takes an array and an index variable. The recursion works as follows: if the index varia
- How can Fibonacci numbers be computed recursively in Java?
"As another example, consider the following Java implementation of the naive recursive Fibonacci sequence. An additional condition has been included to check for “invalid” negative values of n for whi
- How can BigInteger be used for large recursive Fibonacci values?
"Java provides an arbitrary precision data type, BigInteger that can be used to compute arbitrarily large integer values. Since Fibonacci numbers grow exponentially, using an int we could only represe