Hacker News new | ask | show | jobs
by cabalamat 3184 days ago
> What is wrong with writing a state machine using gotos?

Nothing. But the thing they want to do -- altering the datastructure on the fly -- is not the best way to solve the problem.

I would solve this by writing two functions: one that creates an array from a binary tree, and one that creates a doubly-linked list from an array.

Would this use up more RAM and take longer to run? Yes

Would the code be easier to understand (and therefore more bug-free)? Yes