## Turing machine Introduction

Till now we have seen machines which can move in one direction: left to right.

But Turing machine can move in both directions and also it can read from TAPE as well as write on it.

Turing machine can accept recursive enumerable languages

*Turing machine(Automata Machine) was proposed in 1931 by Alan Turing. Back then it was termed as "The Computer".*

### Below is how a TAPE looks like for turing machine:

TAPE is of infinite memory space dvivided into cells. Read/Write head positions over a cell and reads/writes data of cell.Turing machine for a

^{n}b

^{n}| n ≥ 1;

TAPE movement is shown below:

Now we will explain the logic step by step:

- Input is given in the TAPE as "aabb", "B" is BLANK symbol. R/W head will point to first "a" (from left)
- TM will mark first "a" with "X" (custom), and move to right, skipping all "a"s and will stop at first "b"
- TM will mark "b" with "Y" (custom) and move to left till it finds "X" and then stop at one step ahead at "a"
- TM will mark first "a" with "X", and move to right, skipping all "a"s and "Y"s and will stop at "b"
- TM will mark "b" with "Y" and move to left till it finds "X" and then after it there is "Y" that means all "a"s are finished
- TM will move to right to check whether all "b"s are finished. If R/W reaches "B"(BLANK) that means all "b"s are also finished.
*That means TM has acceted the language*

Now we will see how to design

**State Transition Diagram of Turing Machine for above problem:**

- First we start designing by changing "a" to "X" and move right.

- Now when we move right we have to pass all "a"s on the way so we will make a self loop as:

- There could be scenario like after two three steps there are some "Y", so we have to pass them also to get to "b"

- When we get first "b", make it "Y" and move to left:

- When we move to left, we have to pass all the "Y" and "a":

- When we reach "X", we will move to right:

- And repeat these steps till all the a's are finished, to make sure it we will check whether on moving right we get "Y" and we will continue to pass all the "Y"

- If all the b's are finished then we should get a BLANK symbol, TM can move either left or right and we reach final state: