- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies

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

# Design Turing Machine to reverse string consisting of aâ€™s and bâ€™s

Our aim is to design a Turing machine (TM) to reverse a string consisting of a’s and b’s over an alphabet {a,b}.

## Example

**Input** − aabbab

**Output** − babbaa

## Algorithm

Step 1: Move to the last symbol, replace x for a or x for b and move right to convert the corresponding B to „aâ€Ÿ or „bâ€Ÿ accordingly. Step 2: Move left until the symbol left to x is reached. Step 3: Perform step 1 and step 2 until „Bâ€Ÿ is reached while traversing left. Step 4: Replace every x to B to make the cells empty since the reverse of the string is performed by the previous steps.

The transition diagram for Turing Machine (TM) is as follows −

**Let us consider an example to check whether the given input is getting reverse or not **−

**Input string -** abb.

**Expected output -** {bba}

Therefore, the TM is as follows −

- Related Articles
- Design Turing machine for multiplication
- Draw a Turing machine to find 1â€™s complement of a binary number
- Draw a Turing machine to find 2â€™s complement of a binary number
- Design a DFA machine accepting odd numbers of 0â€™s or even numbers of 1â€™s
- Design a Moore machine to generate 1's complement of a binary number.
- Design a DFA of a string with at least two 0â€™s and at least two 1â€™s
- Count subarrays consisting of only 0â€™s and only 1â€™s in a binary array in C++
- Give implementation-level descriptions of a Turing machine?
- Distinguish between Finite Automata and Turing Machine
- Construct a Turing Machine for L = {a^n b^n | n>=1}
- Construct Turing machine for addition
- Construct Turing machine for subtraction
- Explain about a non-deterministic Turing Machine?
- What is Turing Machine in TOC?
- Explain the basic properties of the Turing machine?

Advertisements