Mealy Machine Examples
As we already covered the topic of Automata Mealy Machine. In this session, we will see some Examples of Automata Mealy machine.
Example 1: Mealy Machine for the first complement
Design a Mealy machine to generate the first complement of any given binary input.
Solution
According to the first complement, if the given input is “1”, the output will be “0” and vice versa. Hence, the following is the Mealy Machine of the given question

A Mealy Machine transition table for given example is given below

For instance, take one binary number, 11100, then look at the following table.

Thus, we get 00011, which is the 1’s complement of 11100,
Example 2: Mealy Machine for the 2nd complement
Design a Mealy machine to generate the second complement of any given binary input.
Solution
The following is the Mealy Machine of the given example

A Mealy Machine transition table for the given example is given below

Example 03 – Mealy Machine to print “a” whenever the sequence “01” is encountered
Design a Mealy Machine that prints “a” whenever the sequence “01” is encountered in any input binary string.
Solution
The requirement is that whenever the “01” appears in the string, the output must end with “a”. The following is the desired Mealy Machine.

A Mealy Machine transition table for the given example is given below

For instance, take one binary number, 10111001, and then look at the following table.

As shown in the above table, whenever the “01” occurs in the input string, the output will be “a”.
Example 04 – Mealy Machine to count the occurrences of “a’s”
Construct a Mealy Machine that takes all the strings of a’s and b’s as input and counts the number of a’s in the input string in terms of 1. Where
input Σ = {a,b}, and output △ = {0,1}
Solution
Mealy automata machine, for the given example to counts the number of a’s in the input string in terms of 1, is given below

The Transition Table for the given example (counts the number of a’s in the input string in terms of 1) is given below

Example 05 – Mealy Machine to count occurrences of “abb”
Design a Mealy machine that counts the occurrences of the sequence “abb” In any input string over {a,b}
input Σ = {a,b}, output △ = {0,1}
Solution
Mealy automata machine, to count the occurrences of the sequence “abb” In any input string , is given below

The Mealy Machine transition table provides a count of the occurrences of the sequence “abb” in any given input string 
Example 06 – Mealy Machine to Count Occurrences of “0101”
Design a Mealy machine that counts the occurrences of the sequence “0101” In any input string over {a,b}
Input Σ = {0,1}, Output △ = {0,1}
Solution
A Mealy automaton designed to count the occurrences of the sequence “0101” is presented below.

The Mealy Machine transition table for the given example, which counts the occurrences of the sequence “0101,” is provided below.

Example 07 – Mealy Machine for specific substrings outputs
Design a Mealy machine that takes a set of all strings over {0,1} and gives
- “A” as output if input ends with “10”
- “B” as output if input ends with “11”
- Otherwise gives C as output.
Input Σ = {0,1}, Output △ = {A,B,C}
Solution
Mealy automata machine, for the given example, is given below

The Mealy Machine Transition Table for given example given below 
Example 08 – Mealy Machine for specific substrings outputs
Design a Mealy machine for a binary input sequence such that if it has a
- Substring 101, the machine output A,
- If the input has a substring 110, its output is B;
- Otherwise, it outputs C.
Input Σ = {0,1}, Output △ = {A,B,C}
Solution
Mealy automata machine, for the given example, is given below

The Mealy Machine Transition Table for give example is given below

Example 9– Mealy Machine to generate the remainder after dividing a number by 3
Design a Mealy Machine to generate the remainder after dividing a number by 3 (modulus of 3) in binary
over Σ = {0,1}, △ = {0,1,2}
Solution
Mealy automata machine, to generate the remainder after dividing a number by 3 (modulus of 3), is given below

The transition table of the Mealy Machine for the example of generating the remainder after dividing a number by 3 (modulus of 3) is provided below.

Example 10 – Mealy Machine to generate the remainder after dividing a number by 4
Design a Mealy Machine to generate the remainder after dividing a number by 4 (modulus of 4) in binary
over Σ = {0,1}, △ = {0,1,2,3}
Solution
Automata Mealy Machine, to generate the remainder after dividing a number by 4 (modulus of 4), is given below

The transition table for the Mealy Machine example generates the remainder of a number when divided by 4 (modulus of 4).

Example 11 – Mealy Machine to generate the remainder after dividing a number by 5
Design a Mealy Machine to generate the remainder after dividing a number by 5 (modulus of 5) in binary
over Σ = {0,1}, △ = {0,1,2,3,4}
Solution
Mealy automata machine to generate the remainder after dividing a number by 5 (modulus 5) is described below.

The transition table of the Mealy Machine example generates the remainder after dividing a number by 5 (modulus 5).
