**Prerequisite:** Designing finite automata

Let’s understand the cross product operation in Deterministic Finite Automata (DFA) with help of the below example-

Designing a DFA for the set of string over {a, b} such that string of the language contains even number of a’s and b’s then desired language will be like below-

L = {ε, aa, bb, abab, aabb, baba, bbaa, .......}

Let’s see steps for cross product operation in DFA:

**Step-1:**

Let’s form a DFA which count even number of a’s-

In the below state transition diagram, ‘W’ is the initial state and final state too, which accept language of string containing even number of a’s and any number of b’s.

The language accepted by above DFA is-

L = {ε, aab, b, baa, aabbbbb, aaaab, ..........}

The language does not accepted by above DFA is-

L = {aaa, abbb, baaa, bbaaba, ...........}

**Step-2:**

Let’s form a DFA which count even number of b’s-

In the below state transition diagram, ‘Y’ is the initial state and final state too, which accept language of string containing even number of b’s and any number of a’s.

The language accepted by above DFA is-

L = {ε, bba, a, abb, bbbbaaaa, bbbba, ...........}

The language does not accepted by above DFA is-

L = {bbb, bbba, abbb, aaba, ...........}

**Step-3:**

Here the states of step-1 and step-2 get cross multiplied and produce a result like below-

{W, X} * {Y, Z} = {WY, WZ, XY, XZ}

And in the below, state transition diagram four states {WY, WZ, XY, XZ} used is the result of the cross product of step 1 and 2 states out of which ‘WY’ is the initial and final state too because in step 1 ‘W’ is the initial and final state and in step 2 ‘Y’ is the initial and final state and rest are normal states.

Then the resultant state transition diagram after cross product operation becomes like below-

Thus the above DFA accepts all the language of an even number of a’s and b’s string and the language which is accepted and not accepted by above DFA is given below-

L1 = {ε, aa, bb, abab, aabb, baba, bbaa, .......} L2 = {aaa, aaabb, aaabaabb, aaabb, baaba, bbbaa, .......}

L1 is accepted by above DFA but L2 does not.

Attention reader! Don’t stop learning now. Get hold of all the important CS Theory concepts for SDE interviews with the CS Theory Course at a student-friendly price and become industry ready.

## Recommended Posts:

- Cartesian Product Operation in Relational Algebra
- Difference between Native compiler and Cross compiler
- Difference between Natural join and Cross join in SQL
- Conversion from NFA to DFA
- Minimization of DFA
- DFA for accepting the language L = { a
^{n}b^{m}| n+m=even } - Program to Implement NFA with epsilon move to DFA Conversion
- DFA in LEX code which accepts even number of zeros and even number of ones
- DFA for Strings not ending with "THE"
- DFA of a string with at least two 0’s and at least two 1’s
- Union process in DFA
- DFA machines accepting odd number of 0’s or/and even number of 1’s
- Concatenation process in DFA
- Complementation process in DFA
- DFA of a string in which 2nd symbol from RHS is 'a'
- Reversal process in DFA
- DFA for accepting the language L = {a
^{n}b^{m}| n+m=odd} - DFA of a string in which 3rd symbol from RHS is ‘a’
- Program to construct a DFA which accept the language L = {a
^{n}b^{m}| n mod 2=0, m≥1} - DFA for strings not containing consecutive two a's and starting with 'a'

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.