Chris Kennedy wrote:
John Floren wrote:
I hope the answer is recursion. The answer should
ALWAYS be recursion,
right Professor McCarthy? :)
Only if you have an arbitrary amount of memory available. What if
you're constrained to a handful of automatics?
Two extra pointers... run down the list saving the previous node until
you get to the end. Print the last node. Run down until you get to the
previous node of the last run down the list and print it. Repeat the
previous sentence until you have printed the first node. No copying,
very little extra storage, but you exchange that for long runtime.
I'm a CE, not a programmer, so this is probably wrong.
-chuck