Re: [Algorithms] floodfill
Brought to you by:
vexxed72
From: <mpo...@ed...> - 2001-09-10 17:03:35
|
> > Of course, this method works, but it's a good recipe for stack > > overflows... > > I just don't understand people who code an algorithm with boundless > recursion. To me, re-doing it "iteratively" with a simple priority queue or > list-used-as-stack seems simpler than the recursion, and it often runs > faster, too (if you have a good allocator). For me, real recursion (using the stack of the processor) and iterative versions that use software managed stacks/lists are all recursive by nature. You will run into the same problems, eventually later with the hand made version since you do not have the processor stack frame pushed every call. Of course one should test for errors, but if you need a "flood fill", your are not necesserily happy with a "non crashed but only half filled" result. When I wrote "is a good recipe for stack overflow", I mean it's possible to use methods that do not waste so much memory (and processor time) thus giving you a chance to actually perform the requested operation. Mickael Pointier |