in reply to The Ackermann Function

The way I know is to make a finite state diagram, (see also finite state machine)- in this case the thread moves into three possible states controlled by the ifs in the subroutine, plus a 'final return' state and you would need to identify for each state what conditions result in movement between the states. The fact that branch three generates two calls - one that routes to branch two and one back to branch three means that a thread in state three cannot attain the 'final return' state for the example data. Use the possible data ranges to fill out the state transition table described in the link above to identify which boundary conditions lead to final exit and which not.

-M

Free your mind

Replies are listed 'Best First'.
Re^2: The Ackermann Function
by gjb (Vicar) on Jun 20, 2006 at 19:26 UTC

    I'm afraid this doesn't make sense to me. Are you suggesting that the Ackermann function should simply not be computed if the conditions for branch 3 hold? That would imply that one can only compute A(0, i) and A(i, 0), which is not particularly interesting.

    I may miss your point, but I'd be a bit surprised if FSMs would be useful in this context. Can you show us what you have in mind?

    Just my 2 cents, -gjb-

      Oh - I beg to differ - His Noodly Appendage, the FSM is relevent in EVERY context !

           "For every complex problem, there is a simple answer ... and it is wrong." --H.L. Mencken