Thread: Recursion?
View Single Post
  #10   Spotlight this post!  
Unread 13-12-2003, 16:32
DanL DanL is offline
Crusty Mentor
FRC #0097
Team Role: Mentor
 
Join Date: Jan 2002
Rookie Year: 2001
Location: Somerville, MA
Posts: 682
DanL is just really niceDanL is just really niceDanL is just really niceDanL is just really niceDanL is just really nice
Send a message via AIM to DanL
Re: I agree recursion is evil.

Quote:
Originally Posted by Rickertsen2
Recursion is a bad pracice on any platform and should be avoided....
That statement is completely false. The use of recursion completely depends on the problem at hand.

For example, the non-recursive solution to the classic Towers of Hanoi problem is significantly more complicated than the recursive solution.

Or, a non-recursive program to find and show the correct path through a maze is significantly more difficult to implement than the recursive solution.

Recursion is an essential technique for any application which uses a tree data structure. I've written several web application that require directory traversal... without recursion, these would have been near impossible.

I'm not going to disagree with you that recursion is a bad practice on the robot controller due to its limited memory and stack, but to state that recursion is a bad practice and should be avoided is completely false. There are advantages and disadvantages to recursive algorithms vs. iterative algorithms - in some cases, the recursive solution is better than the iterative solution, in other cases, it isn't. It depends completely upon the problem at hand.
__________________
Dan L
Team 97 Mentor
Software Engineer, Vecna Technologies