Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Behold! The power of recursion.

by pg (Canon)
on Oct 18, 2004 at 03:16 UTC ( [id://400044]=note: print w/replies, xml ) Need Help??


in reply to Re: Behold! The power of recursion.
in thread Behold! The power of recursion.

"It is worth noting that while an iterative solution will almost inevitably run faster than a recursive solution, a good recursive solution is often quite terse."

Fully agree. Although this demos recursion, it is not a good example to demo the NEED of recursion.

A typical situation where recursion becomes a clearer solution is that, you need complex stack data structure to remember things otherwise, which is not the case here.

"A classic very simple example is the calculation of factorial n!"

My favorite is Hanoi Tower problem.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://400044]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-29 10:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found