At 12:31 -0700 6/4/04, ALTENBACH,CHRISTIAN wrote:
Quoting Scott Hannahs <[EMAIL PROTECTED]
> It makes an interesting story but is not the best
>way to approach the problem.
>
>'glad you brought up your recursive demo. I compared it with my entry in the
>recent LabVIEW Zone Coding challenge for factorials.
>
>( http://www.ni.com/devzone/lvzone/codechallenge6_results.htm )
>
>For "12!" it is 3000x slower (5 ms vs. 2 microseconds) while mine does more
>because it formats the output to a string.

Yes, recursion is better in some cases and not others.  Actually for large numbers, 
the approximation X^X*exp(-x) works fastest!   But it can be a very easy thing to 
program and maintain.  A better example is to solve a maze where you follow the turns 
exhaustively.  Almost anything that can be done recursively can be done with arrays.

BUT, you save time and reliability in clearer, cleaner code.  This form of recursion 
is deadly slow because VI server is MUCH MUCH MUCH slower than a direct sub-vi.  It 
may be the best way to approach a problem but not the fastest in execution.

-Scott


Reply via email to