It is really more of a question of the type of problem and the solution approach in general. For example, one can find the intersection of two lines with a simple equation, but that equation depends on the dimension the lines are in (2D, 3D, ...). If one were working in 2D space only, then the simple equation is the simplest solution. However if one wanted a function that would work in any space, then setting up the problem as a matrix and solving it recursively might be a better approach.
One more concrete consideration is that if you find yourself tackling a problem with nested looping and the algorithm at each level is mostly the same, then perhaps recursion would be better.
Some time ago I wrote a recursion article for an audience using Lingo scripting (in Macromedia Director). The actual code at the end is Lingo (not all that different) but the thrust of the article is constructing a recursive solution for matrix type problems (more than one unknown in an equation).
I put the pdf in my .Mac account if you wish to view it.
http://homepage.mac.com/lee_cullens/ A_Simple_Recursive_Solution_(article_v2).pdf
Of course, with Python we have math packages to do the grunt work, but it helps to understand the problem.
Lee C
On Apr 14, 2005, at 21:06, [EMAIL PROTECTED] wrote:
I've seen a couple of nice tutorials on recursion, and a lot of awful ones. The latter always trot out the fibonacci and factorial examples for some reason. And that's about it! The good ones showed me how to trace through recursive calls and gave me practical examples(tictactoe, magic squares, Tower of Hanoi, 4-Square, etc)
What I want to know is this: what are other specific situations where a recursive algorithm would be better or easier to program than an iterative one?
_______________________________________________ Tutor maillist - Tutor@python.org http://mail.python.org/mailman/listinfo/tutor