Quote:
|
Originally Posted by SuperDanman
For example, the non-recursive solution to the classic Towers of Hanoi problem is significantly more complicated than the recursive solution.
|
http://www.kernelthread.com/hanoi/
Quote:
|
Originally Posted by SuperDanman
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.
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.
|
Yes, recursion is very helpful for the path finding algorithm.
Though, I am rather unimpressed with the stack size of the Microchip products. The 16 bit motorolla microprocessor that I implemented said pathfinding algorithm on was nice because the stack could be of any size (up to the limit of RAM).
Back towards the topic... Recursion can greatly simply many algorithms. Fibonachi is a good example of that. Infact implementing fibonachi as recersive and iterative tends to be a common problem given by CS-101 professors, to help illustrate recursion.
Though however, with recursion you can trade simplified code(and possibly faster) for increased memory useage. So, to sum up slightly, the use of recursion, iteration, (or anything else) really needs to be determined based on what your goals are (speed, size, time to impliment) and what resources you have available.
Of course that summary could be applied to any engineering decision.