# Conversion of Moore to Mealy machine (Set 4)

**Prerequisite:** Mealy and Moore Machines, Difference between Mealy machine and Moore machine

In this article, we shall see a conversion of Moore to Mealy machine-

**State Transition Diagram of a Moore machine:-**

Above Moore machine takes set of all string over {a, b} as input and count the number of substrings as ‘ab’ i.e, on getting ‘ab’ as the input substrings it gives ‘1’ as the output thus on counting number of outputs ‘1’, it gives the count of substrings as ‘ab’ as well.

Now we need to transform the above transition diagram of Moore machine to equivalent Mealy machine transition diagram. Steps for the required conversion are given below:-

**Step-1:**Formation of State Transition Table of the above Moore machine-

In the above transition table, States ‘X’, ‘Y’ and ‘Z’ are kept in the first column which on getting ‘a’ as the input it transits to ‘Y’, ‘Y’ and ‘Y’ states respectively, kept in the second column and on getting ‘b’ as the input it transits to ‘X’, ‘Z’ and ‘X’ states respectively, kept in the third column. In the fourth column under Δ, there are corresponding outputs of the first column states. In the table, An arrow (→) indicates the initial state.**Step-2:**Formation of Transition Table for Mealy machine from above Transition Table of Moore machine-

Below transition table is going to be formed with the help of the above table and its entries just by using the corresponding output of the states of the first column and placing them in the second and third column accordingly.

In the above table, the states in the first column like ‘X’ on getting ‘a’ as the input it goes to a state ‘Y’ and gives ‘0’ as the output and on getting ‘b’ as the input it goes to the state ‘X’ and gives ‘0’ as the output and so on for the remaining states in the first column. In the table, An arrow (→) indicates the initial state.

**Step-3:**Then finally we can form the state transition diagram of Mealy machine with help of it’s above transition table.

The required diagram is shown below-

Above Mealy machine takes set of all string over {a, b} as input and count the number of substrings as ‘ab’ i.e, on getting ‘ab’ as the input substrings it gives ‘1’ as the output thus on counting number of outputs ‘1’, it gives the count of substrings as ‘ab’ as well.

**Note:** While converting from Moore to Mealy machine the number of states remains same for both Moore and Mealy machine but in case of Mealy to Moore conversion it does not give the same number of states.

Don’t stop now and take your learning to the next level. Learn all the important concepts of Data Structures and Algorithms with the help of the most trusted course: DSA Self Paced. Become industry ready at a student-friendly price.

## Recommended Posts:

- Conversion of Moore to Mealy machine (Set 9)
- Conversion of Moore to Mealy machine (Set 10)
- Difference between Mealy machine and Moore machine
- Mealy and Moore Machines in TOC
- Moore and Mealy machines to count number of substring ‘ab’
- Moore and Mealy machines to produce 'A', 'B', 'C' depends on inputs that end with ’10’ or with ’11’ else other
- Mealy Machine for 1's Complement
- Design a mealy machine for 2's complement
- Design 101 sequence detector (Mealy machine)
- Conversion from NFA to DFA
- Conversion of Epsilon-NFA to NFA
- Minimal to Canonical Form Conversion
- Program for Octal to Decimal Conversion
- Program for Decimal to Binary Conversion
- Program for Binary To Decimal Conversion
- Program for Decimal to Octal Conversion
- Conversion of Binary number to Base 4 system
- Program to Implement NFA with epsilon move to DFA Conversion
- Turing Machine in TOC
- Construct a Turing machine for L = {a
^{i}b^{j}c^{k}| i*j = k; i, j, k ≥ 1}

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.