I've been asked to create a formal Turing Machine (by means of a transition function) to which takes a string $a^n \in$ {a}* and decides whether it is an even or odd length.
What I have made is the following
({E, O, H}, {a, _, >}, P, E, {H})
Where P is
State, Letter $\to$ P(State/Letter)
E, a $\to$ (O, _)
E, _ $\to$ (E, $\to$)
E, > $\to$ (E, $\to$)
O, a $\to$ (E, _)
O, _ $\to$ (O, $\to$)
O, > $\to$ (O, $\to$)
I'm fairly sure I've got the right idea but I don't know how exactly I am meant to finish. How do I 'finish' and where in the input do I start reading from?
Try to put more structure here: The states $\{E, O, H_E, H_O\}$ are meant to denote even, odd and halted even, odd states. The Alphabet may only consist of $\{a, \Box\}$ i.e. the letter and the blank. The algorithm we think up is
Now we can say the transition function is given by $$(s,l) \mapsto \delta(s, l) = (s, l, d)\\ (E, \Box) \mapsto (H_E, -, -) \\ (E, a) \mapsto (O, -, \rightarrow) \\ (O, \Box) \mapsto (H_O, -, -) \\ (O, a) \mapsto (E, -, \rightarrow)$$
The halting states are $H_E, H_O$. Our TM is then given by $$TM = (\{E, O, H_E, H_O\}, \{a, \Box\}, \delta, E, \{H_E, H_O\})$$ We consider two acceptance rules: