Java-Gaming.org
 Featured games (81) games approved by the League of Dukes Games in Showcase (497) Games in Android Showcase (114) games submitted by our members Games in WIP (563) games currently in development
 News: Read the Java Gaming Resources, or peek at the official Java tutorials
 Home Help Search Login Register
Pages: [1]
 ignore  |  Print
 Recursion and Java  (Read 1375 times) 0 Members and 1 Guest are viewing this topic.
K.I.L.E.R

Senior Member

Java games rock!

 « Posted 2005-03-04 04:28:12 »

With Java hotspot compiler inlining frequently used methods, does that mean recursion has the same efficiency as a loop?

Vorax:
Is there a name for a "redneck" programmer?

Jeff:
Unemployed.
phazer

Junior Member

Come get some

 « Reply #1 - Posted 2005-03-04 05:31:02 »

Quote
With Java hotspot compiler inlining frequently used methods, does that mean recursion has the same efficiency as a loop?

Yes, if you do tail recursion it is as efficient as a iterative solution. See:

http://www-106.ibm.com/developerworks/java/library/j-diag8.html

K.I.L.E.R

Senior Member

Java games rock!

 « Reply #2 - Posted 2005-03-08 07:53:59 »

So this doesn't apply to other forms of recursion?

Vorax:
Is there a name for a "redneck" programmer?

Jeff:
Unemployed.
 Games published by our own members! Check 'em out!
phazer

Junior Member

Come get some

 « Reply #3 - Posted 2005-03-08 09:55:24 »

Quote
So this doesn't apply to other forms of recursion?

Many solutions implemented using recursion can be very hard to translate into an iterative counterpart (for example, double recursion). A recursive solution is often less efficient than an iterative counterpart because of the additional stack handling required, but it all depends on the quality of the iterative solution.

Don't optimize prematurely and never without profiling data. A recursive solution is often much shorter, easier to read, implement and verify than an iterative counterpart, so start with a recusive solution if that fits for your problem.

Pages: [1]
 ignore  |  Print

You cannot reply to this message, because it is very, very old.

 Add your game by posting it in the WIP section, or publish it in Showcase. The first screenshot will be displayed as a thumbnail.
 BurntPizza (17 views) 2014-09-19 03:14:18 Dwinin (34 views) 2014-09-12 09:08:26 Norakomi (61 views) 2014-09-10 13:57:51 TehJavaDev (84 views) 2014-09-10 06:39:09 Tekkerue (42 views) 2014-09-09 02:24:56 mitcheeb (64 views) 2014-09-08 06:06:29 BurntPizza (47 views) 2014-09-07 01:13:42 Longarmx (35 views) 2014-09-07 01:12:14 Longarmx (39 views) 2014-09-07 01:11:22 Longarmx (36 views) 2014-09-07 01:10:19
 BurntPizza 38x Riven 18x Rayvolution 17x princec 17x basil_ 16x ags1 16x KevinWorkman 15x kevglass 12x LiquidNitrogen 11x nsigma 11x theagentd 11x HeroesGraveDev 9x The Lion King 7x SHC 6x Gibbo3771 6x cylab 6x
 List of Learning Resources2014-08-16 18:40:00List of Learning Resources2014-08-06 03:33:27Resources for WIP games2014-08-02 00:20:17Resources for WIP games2014-08-02 00:19:50List of Learning Resources2014-08-01 00:29:50List of Learning Resources2014-08-01 00:26:06List of Learning Resources2014-07-31 19:54:12HotSpot Optionsby dleskov2014-07-08 09:59:08
 java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org