- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP

- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who

The Turing machine (TM) is more powerful than both finite automata (FA) and pushdown automata (PDA). They are as powerful as any computer we have ever built.

A Turing machine can be formally described as seven tuples

(Q,X, Σ,δ,q0,B,F)

Where,

Q is a finite set of states

X is the tape alphabet

Σ is the input alphabet

δ is a transition function: 𝛿:QxX→QxXx{left shift, right shift}

q0 is the initial state

B is the blank symbol

F is the final state.

A Turing Machine (TM) is a mathematical model which consists of an infinite length tape divided into cells on which input is given. It consists of a head which reads the input tape. A state register stores the state of the Turing machine.

After reading an input symbol, it is replaced with another symbol, its internal state is changed, and it moves from one cell to the right or left. If the TM reaches the final state, the input string is accepted, otherwise rejected.

Turing machines have a read/write head. So we can write on the tape.

Now, let us construct a Turing machine which accepts equal number of a’s and b’s,

The language it is generated is L ={ a^{n}b^{n}| n>=1}, the strings that are accepted by the given language is −

L= {ab, aabb, aaabbb, aaaabbbb,………}

**Example**

Consider n=3 so, a^{3}b^{3} , the tape looks like -

B= blank

We need to convert every ‘a’ as X and every ‘b’ as Y. If the Turing machine contains an equal number of X and Y then it reaches the final state.

**Step 1** − Consider the initial state as q0. This state replace ‘a’ as X and move to right, now state changes for q0 toq1, so the transition function is −

δ(q0, a) = (q1,X,R)

**Step 2** − Move right until you see the blank symbol.

δ(q1, a) = (q1,a,R)

δ(q1, b) = (q1,b,R)

After reaching the blank symbol B, move left and change the state to q2, because we need to change the last ‘b’ to Y.

δ(q1, B) = (q2,B,L) //1st iteration δ(q1, Y) = (q2,Y,L) // remaining iterations

**Step 3** − When we see the symbol ‘b’, replace it as Y and change the state to q3 and move left.

δ(q2, B) = (q3,Y,L)

**Step 4** − Move to the left until reach the symbol X.

δ(q3, a) = (q3,a,L) δ(q3, b) = (q3,b,L)

When we reach X move right and change the state as q0, and the next iteration is started.

After replacing every ‘a’ and ‘b’ as X and Y by changing the states to q0 to q4.

δ(q0, Y) = (q4,Y,N)

N represents No movement.

X | X | X | Y | Y | Y | B | B | ........................... |

q4 is the final state and q0 is the initial state of the Turing Machine, the intermediate states are q1, q2, q3.

The transition diagram is as follows −

- Related Questions & Answers
- Design Turing Machine to reverse string consisting of a’s and b’s
- 1’s and 2’s complement of a Binary Number?
- Count subarrays with equal number of 1’s and 0’s in C++
- Design DFA for language over {0,1} accepting strings with odd number of 1’s and even number of 0’s
- Design a DFA of a string with at least two 0’s and at least two 1’s
- Design a DFA machine accepting odd numbers of 0’s or even numbers of 1’s
- Sort an arrays of 0’s, 1’s and 2’s using C++
- Sort an arrays of 0’s, 1’s and 2’s using Java
- Find yesterday’s, today’s and tomorrow’s date in Python
- Construct DFA of alternate 0’s and 1’s
- 10’s Complement of a decimal number?
- Difference Between Prim’s and Kruskal’s Algorithm
- Faraday’s Laws and Lenz’s Law of Electromagnetic Induction
- Count the number of 1’s and 0’s in a binary array using STL in C++
- Maximum length of segments of 0’s and 1’s in C++

Advertisements