
- Automata Theory - Applications
- Automata Terminology
- Basics of String in Automata
- Set Theory for Automata
- Finite Sets and Infinite Sets
- Algebraic Operations on Sets
- Relations Sets in Automata Theory
- Graph and Tree in Automata Theory
- Transition Table in Automata
- What is Queue Automata?
- Compound Finite Automata
- Complementation Process in DFA
- Closure Properties in Automata
- Concatenation Process in DFA
- Language and Grammars
- Language and Grammar
- Grammars in Theory of Computation
- Language Generated by a Grammar
- Chomsky Classification of Grammars
- Context-Sensitive Languages
- Finite Automata
- What is Finite Automata?
- Finite Automata Types
- Applications of Finite Automata
- Limitations of Finite Automata
- Two-way Deterministic Finite Automata
- Deterministic Finite Automaton (DFA)
- Non-deterministic Finite Automaton (NFA)
- NDFA to DFA Conversion
- Equivalence of NFA and DFA
- Dead State in Finite Automata
- Minimization of DFA
- Automata Moore Machine
- Automata Mealy Machine
- Moore vs Mealy Machines
- Moore to Mealy Machine
- Mealy to Moore Machine
- Myhill–Nerode Theorem
- Mealy Machine for 1’s Complement
- Finite Automata Exercises
- Complement of DFA
- Regular Expressions
- Regular Expression in Automata
- Regular Expression Identities
- Applications of Regular Expression
- Regular Expressions vs Regular Grammar
- Kleene Closure in Automata
- Arden’s Theorem in Automata
- Convert Regular Expression to Finite Automata
- Conversion of Regular Expression to DFA
- Equivalence of Two Finite Automata
- Equivalence of Two Regular Expressions
- Convert Regular Expression to Regular Grammar
- Convert Regular Grammar to Finite Automata
- Pumping Lemma in Theory of Computation
- Pumping Lemma for Regular Grammar
- Pumping Lemma for Regular Expression
- Pumping Lemma for Regular Languages
- Applications of Pumping Lemma
- Closure Properties of Regular Set
- Closure Properties of Regular Language
- Decision Problems for Regular Languages
- Decision Problems for Automata and Grammars
- Conversion of Epsilon-NFA to DFA
- Regular Sets in Theory of Computation
- Context-Free Grammars
- Context-Free Grammars (CFG)
- Derivation Tree
- Parse Tree
- Ambiguity in Context-Free Grammar
- CFG vs Regular Grammar
- Applications of Context-Free Grammar
- Left Recursion and Left Factoring
- Closure Properties of Context Free Languages
- Simplifying Context Free Grammars
- Removal of Useless Symbols in CFG
- Removal Unit Production in CFG
- Removal of Null Productions in CFG
- Linear Grammar
- Chomsky Normal Form (CNF)
- Greibach Normal Form (GNF)
- Pumping Lemma for Context-Free Grammars
- Decision Problems of CFG
- Pushdown Automata
- Pushdown Automata (PDA)
- Pushdown Automata Acceptance
- Deterministic Pushdown Automata
- Non-deterministic Pushdown Automata
- Construction of PDA from CFG
- CFG Equivalent to PDA Conversion
- Pushdown Automata Graphical Notation
- Pushdown Automata and Parsing
- Two-stack Pushdown Automata
- Turing Machines
- Basics of Turing Machine (TM)
- Representation of Turing Machine
- Examples of Turing Machine
- Turing Machine Accepted Languages
- Variations of Turing Machine
- Multi-tape Turing Machine
- Multi-head Turing Machine
- Multitrack Turing Machine
- Non-Deterministic Turing Machine
- Semi-Infinite Tape Turing Machine
- K-dimensional Turing Machine
- Enumerator Turing Machine
- Universal Turing Machine
- Restricted Turing Machine
- Convert Regular Expression to Turing Machine
- Two-stack PDA and Turing Machine
- Turing Machine as Integer Function
- Post–Turing Machine
- Turing Machine for Addition
- Turing Machine for Copying Data
- Turing Machine as Comparator
- Turing Machine for Multiplication
- Turing Machine for Subtraction
- Modifications to Standard Turing Machine
- Linear-Bounded Automata (LBA)
- Church's Thesis for Turing Machine
- Recursively Enumerable Language
- Computability & Undecidability
- Turing Language Decidability
- Undecidable Languages
- Turing Machine and Grammar
- Kuroda Normal Form
- Converting Grammar to Kuroda Normal Form
- Decidability
- Undecidability
- Reducibility
- Halting Problem
- Turing Machine Halting Problem
- Rice's Theorem in Theory of Computation
- Post’s Correspondence Problem (PCP)
- Types of Functions
- Recursive Functions
- Injective Functions
- Surjective Function
- Bijective Function
- Partial Recursive Function
- Total Recursive Function
- Primitive Recursive Function
- μ Recursive Function
- Ackermann’s Function
- Russell’s Paradox
- Gödel Numbering
- Recursive Enumerations
- Kleene's Theorem
- Kleene's Recursion Theorem
- Advanced Concepts
- Matrix Grammars
- Probabilistic Finite Automata
- Cellular Automata
- Reduction of CFG
- Reduction Theorem
- Regular expression to ∈-NFA
- Quotient Operation
- Parikh’s Theorem
- Ladner’s Theorem
Example of Turing Machine
In the previous chapter, we presented the concept of Turing machine (TM) and how we can form a TM for a problem. In this chapter, we will see some further examples of Turing machines with which it will be clear for us how the TM can be made using instantaneous description and state diagrams for a better view.
Example 1: Turing Machine for WWR
Let us look at a Turing Machine that accepts the language L = {WWR, where W ∈ (a, b)+}. Here, WR is the reverse of W.
Transition Table
Take a look at its Transition Table −
State | a | b | B | X | Y |
---|---|---|---|---|---|
q0 | (q1, X, R) | (q4, Y, R) | - | (qf, X, H) | (qf, Y, H) |
q1 | (q1, a, R) | (q1, b, R) | (q2, B, L) | (q2, X, L) | (q2, Y, L) |
q2 | (q3, X, L) | - | - | - | - |
q3 | (q3, a, L) | (q3, b, L) | - | (q0, X, R) | - |
q4 | (q4, a, R) | (q4, b, R) | (q5, B, L) | (q5, X, L) | (q5, Y, L) |
q5 | - | (q6, Y, L) | - | - | - |
q6 | (q6, a, L) | (q6, b, L) | - | - | (q0, Y, R) |
Note: "-" indicates no transition for that state-symbol pair.
Transition Diagram
Here is its Transition Diagram −

Explanation of the Turing Machine
This Turing Machine works as follows −
- It replaces the first symbol (a or b) with X or Y.
- It moves to the end of the string.
- It checks if the last symbol matches the first one.
- It moves back to the start and repeats the process for the next symbol.
- If all symbols match, it accepts the string.
Processing "abaaaaba"
Let's see how this Turing Machine processes the string "abaaaaba" −
(q0, abaaaaba) → (q1, Xbaaaaba) → (q1, Xbaaaaba) → (q1, XbaaaabB) → (q2, XbaaaabB) → (q3, XbaaaabX) → (q3, XbaaaabX) → (q0, XbaaaabX) → (q4, XYaaaabX) → (q4, XYaaaabX) → (q5, XYaaaabX) → (q6, XYaaaaYX) → (q0, XYaaaaYX) → (q1, XYXaaaYX) → (q1, XYXaaaYX) → (q2, XYXaaaYX) → (q3, XYXaaXYX) → (q0, XYXaaXYX) → (q1, XYXXAXYX) → (q2, XYXXAXYX) → (q3, XYXXXXYX) → (q0, XYXXXXYX) → (qf, XYXXXXYX) [Halt]
The Turing Machine accepts the string "abaaaaba" as it is of the form WWR.
Example 2: Turing Machine for Palindromes
Last one is similar to the palindrome but in real case, a palindrome could be of odd length or even length. Let us see the Turing Machine that accepts the language L = {set of all palindromes over a, b}.
Transition Table
Here is its Transition Table −
State | a | b | B |
---|---|---|---|
q1 | (q2, B, R) | (q5, B, R) | (q7, B, H) |
q2 | (q2, a, R) | (q2, b, R) | (q3, B, L) |
q3 | (q4, B, L) | - | (q7, B, H) |
q4 | (q4, a, L) | (q4, b, L) | (q1, B, R) |
q5 | (q5, a, R) | (q5, b, R) | (q6, B, L) |
q6 | - | (q4, B, L) | (q7, B, H) |
Transition Diagram
Take a look at tits Transition diagram −

Explanation of the Turing Machine
This Turing Machine operates as follows −
- It replaces the first symbol with a blank (B).
- It moves to the end of the string.
- It checks if the last symbol matches the first one.
- It replaces the last symbol with a blank and moves back to the start.
- It repeats this process until all symbols are checked.
- If all symbols match, it accepts the string as a palindrome.
Let's see how this Turing Machine processes different strings −
Null String
(q1,B)→(q7,B)[Halt]
The null string is accepted as a palindrome.
String "a"
(q1,aB)→(q2,BB)→(q3,BB)→(q7,BB)[Halt]
The string "a" is accepted as a palindrome.
String "aba"
(q1,abaB)→(q2,BbaB)→(q2,BbaB)→(q3,BbaB)→(q4,BBBB)→(q1,BBBB)→(q7,BBBB)[Halt]
The string "aba" is accepted as a palindrome.
String "baab"
(q1,baabB)→(q5,BaabB)→(q5,BaabB)→(q6,BaaB)→(q4,BaBB)→(q1,BaBB)→(q2,BBaBB)→(q3,BBABB)→(q7,BBBBB)[Halt]
The string "baab" is accepted as a palindrome.
Example 3: Turing Machine for an bn cn
Finally, let's look at a Turing Machine that accepts the language L = an bn c+, where n ≥ 1.
This language is context-sensitive. It consists of strings with equal numbers of 'a', 'b', and 'c' in that order. The number of each symbol must be at least 1.
Transition Table
Here is its Transition Table −
State | a | b | c | B | X | Y | Z |
---|---|---|---|---|---|---|---|
q1 | (q2, X, R) | - | - | - | - | (q5, Y, R) | - |
q2 | (q2, a, R) | (q3, Y, R) | - | - | - | (q2, Y, R) | - |
q3 | - | (q3, b, R) | (q4, Z, L) | - | - | - | (q3, Z, R) |
q4 | (q4, a, L) | (q4, b, L) | - | - | (q1, X, R) | (q4, Y, L) | (q4, Z, L) |
q5 | - | - | - | - | - | (q5, Y, R) | (q6, Z, R) |
q6 | - | - | - | (qf, B, H) | - | - | (q6, Z, R) |
Transition Diagram
Here is its Transition Diagram −

Conclusion
In this chapter, we presented detailed examples of three different machines including string with its reverse, then palindrome and finally an bn cn. There are many such examples that can be solved using Turing Machine.