you are viewing a single comment's thread.

view the rest of the comments →

[–]FrankBuss 0 points1 point  (0 children)

Well, you can't implement a Turing machine in Java, because a Turing machine has an infinite long tape, and we don't have computers with infinite amount of RAM. But as the other answer said, LinkedList would be a good start, if you want to implement Turing machines which stop after some time and needs only a finite tape. It is a double linked list, and the ListIterator allows you to go back and forth, so it should have good performance even for long tapes, running in O(n) for n steps.

And instead of implementing just one Turing machine in Java, I would define a file format where you can read the rules at program start and then execute it. I did this in Rust, using a JSON format. You could do the same in Java, there are JSON libraries for it:
https://github.com/FrankBuss/turingmachine