Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Recursion challenge
#12
Well, you seem to be against recursion. It's slow and a stack hog but in problems involving a limited number of calls it can be the simplest solution. Obviously it's no good to calculate factorials but it's the best solution when a tree must be explored, as Moneo said.

Loose Caboose: Your floodfill example is only an exampe of a poor algorithm. It just generates calls without knowing if there is a former call for the same point. With an iterative implementation you should create a huge queue array or you would have a lot of gaps. There are much better ways to floodfill. The one you posted is good too teach what's floodfill, you can see it at a first glance. Big Grin

To keep the thread open (and again not a good example of what recursion should be used on). A mcd calculation

Code:
DECLARE FUNCTION mcd& (a&, b&)
PRINT mcd&(320, 240)

FUNCTION mcd& (a&, b&)
c& = a& MOD b&
IF c& THEN
    mcd& = mcd&(b&, c&)
ELSE
   mcd& = b&
END IF
END FUNCTION
Antoni
Reply


Messages In This Thread
Recursion challenge - by Antoni Gual - 06-26-2003, 08:04 PM
Recursion challenge - by Antoni Gual - 06-27-2003, 12:37 AM
Recursion challenge - by Moneo - 06-28-2003, 09:49 AM
I beg to differ. - by Agamemnus - 06-30-2003, 05:11 AM
Re: I beg to differ. - by Moneo - 06-30-2003, 06:22 AM
nah - by Agamemnus - 06-30-2003, 09:07 PM
Recursion challenge - by Antoni Gual - 07-01-2003, 01:13 AM
Recursion challenge - by Moneo - 07-01-2003, 02:25 AM
Recursion challenge - by LooseCaboose - 07-01-2003, 05:02 AM
To LooseCaboose: Re Gray's Code - by Moneo - 07-01-2003, 05:38 AM
Recursion challenge - by LooseCaboose - 07-01-2003, 05:52 AM
Recursion challenge - by Antoni Gual - 07-02-2003, 01:30 AM
Recursion challenge - by LooseCaboose - 07-03-2003, 03:30 PM
Recursion challenge - by Moneo - 07-03-2003, 11:14 PM
Recursion challenge - by Hexadecimal Disaster - 07-04-2003, 01:33 AM
Recursion challenge - by LooseCaboose - 07-04-2003, 09:25 AM
To LooseCaboose: - by Moneo - 07-04-2003, 09:15 PM
Recursion challenge - by LooseCaboose - 07-05-2003, 07:39 AM
To LooseCaboose: - by Moneo - 07-05-2003, 08:31 AM
Recursion challenge - by na_th_an - 07-12-2003, 06:43 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)