I have an algorithm I need to implement, which jumps around it's code a lot, lot's of conditional check and skipping steps, going back to previous steps, and all that jazz.
It's probably implementable with loop and ifs, but it would be a huge mess which would be terribly hard to maintain and debug.
So than I though of writing each 'subsection' of the algorithm as a separate function and handling it like that, with all those functions calling each other. but this algorithm will be running a long time (it's for a NPcomplete problem, so yea...), so I'm pretty sure this will at some point result in a stack overflow.
So than the last option I could think of was using goto's. Now I always hear that once you start using goto's you should seriously reconsider your design, so that's why I'm asking if there's a better way to do this?
Oke here is the pseudo code:
As you can see it jumps around a and does lot's of check and conditional skips and stuff. I though about just adding the labels exactly as described in this pseudo code and using goto's exactly as described in the code. The alternative I was talking about with functions would be putting each of the point of the algorithm in a different function, but for reasons mentioned I do not think this is a good idea