Paul,
Thanks a bunch to all of you folks. This has been a good learning experience.
Best,
DD
>>What 'types' of programs do you recommend using recursion? I've used them for multi-level types of organizations and relationships where they seem to do well. I'm curious as to other types of applications as well.
>
>Here's the rule of thumb given by one of my professors:
>
>You assume that:
>1. You have a little devil-slave that knows how to calculate MyProblem(x)
>and
>2. You know how to go from y to x
>and
>3. You know when to stop
>
>Then it's easy to apply a recursive solution:
>
>func MyProblem
>lparam y
>if MyStopCondition(y)
> return whatever && This is my precious knowledge
>else
> x = NextStepParam(y) && Again, my knowledge
> a = MyProblem(x) && Again, my knowledge
> return Operate(a, y) && Again, my knowledge
>endif
>
>And, as it can be seen, there's no little devil involved at all... :) The devil-slave is just the above pattern. In practice,
>there are three important things: the above pattern, the stop condition (very important to be sure that it will
>be meet for all cases) and the formula to go from one step to the other (params and result).
>
>Obviously, NextStepParam and Operate can be simple formulas.
>
>Vlad
Best,
DD
A man is no fool who gives up that which he cannot keep for that which he cannot lose.
Everything I don't understand must be easy!
The difficulty of any task is measured by the capacity of the agent performing the work.