An algorithm problem
Maric Michaud
maric at aristote.info
Wed May 31 05:42:08 EDT 2006
Le Mercredi 31 Mai 2006 08:58, Bo Yang a écrit :
> RuntimeError: maximum recursion depth exceeded
It's tied to the recursive call to the ring function, python raises a limit to
recursive calls to avoid infinite recursion.
You can just adjust the limit using these two lines when you call the function
ring :
import sys
sys.setrecursionlimit(10000) # or whatever, the default is 1000
and set back the limit to its default after the call.
Note that function calls are memory expensive and the recursive implementation
of an algorithm must be considered (in particular in python) as an "elegant
but not optimized" one.
--
_____________
Maric Michaud
_____________
Aristote - www.aristote.info
3 place des tapis
69004 Lyon
Tel: +33 426 880 097
More information about the Python-list
mailing list