Link Details

Link 1045589 thumbnail
User 427475 avatar

By Xiaoran Wang
via programcreek.com
Published: Oct 08 2013 / 22:36

A set of simple Java code examples to explain recursion vs iteration.
  • 12
  • 0
  • 1650
  • 2037
User 457909 avatar

DerHeiligste replied ago:

0 votes Vote down Vote up Reply

This is a nice article. It would be nice, though, if it would mention recursive methods that use an accumulator. For example, your Fibonacci method could be something like this: function fib(n) { return fib2(n,1,1); } function fib2(n, a, b) { if (n > 2) { return fib2(n - 1, b, a+b) } else { return b; } }

Add your comment


Html tags not supported. Reply is editable for 5 minutes. Use [code lang="java|ruby|sql|css|xml"][/code] to post code snippets.

Apache Hadoop
Written by: Piotr Krewski
Featured Refcardz: Top Refcardz:
  1. Play
  2. Akka
  3. Design Patterns
  4. OO JS
  5. Cont. Delivery
  1. Play
  2. Java Performance
  3. Akka
  4. REST
  5. Java