A two-way finite automaton is like a robot with two hands, that can read a sequence of symbols and perform actions based on what it reads. Imagine a boy gives the robot a list of tasks, like sorting toys into two piles based on their color.
The robot starts at the beginning of the list and reads the first symbol. If it does what the boy instructed, it moves forward to the next symbol on the list. If not, it goes back to the previous symbol to try a different action with its other hand.
For example, if the robot reads a red toy, it puts it in the red pile and moves forward. If it reads a green toy, it puts it in the green pile and moves forward. But if it reads a toy that is not red or green, it goes back to the previous toy to try a different action.
Ultimately, the robot will either finish sorting the entire list or go back and forth between symbols forever if it cannot find a proper action to perform.
In computer science, people use two-way finite automata like this robot to solve problems like recognizing if a sequence of symbols is a valid pattern or language.