Design a Deterministic Finite Automata (DFA) for 'abab'

2.6k Views Asked by At

Problem

Design a deterministic finite automata (dfa) that satisfies the following:

{ w | w has 'abab' as a substring}

Hence, w can be ε, abab, abababab, etc.

Attempt

This was my first trial. It creates strings with ab as a substring, but not necessarily abab. Trial 1 This is my second trial. I, in short, don't know if I'm right. Trial 2

I apologize for the major space in the drawings, hope they are legible.

Notes

I'd also greatly appreciate it if you could provide the quintuple, M = (Q, Σ, s, F, δ) for this dfa.

Thank you in advance!

1

There are 1 best solutions below

0
On

I don't see why, $\epsilon$ is in $L$, where $L = \{ w \in \sum^* \mid \exists (u_0, u_1, u_2, u_3, u_4) \in \sum^{5*}, w = u_0au_1bu_2au_3bu_4\}$.

Hence for me, there is a problem with your $DFA$, because $q_0$ is a final state (so it accepts $\epsilon$).

A solution could be the following $NFA = (\{q_0, q_1, q_2, q_3, q_4\}, \{a, b\}, q_0, \{q_4\}, \delta)$ :

enter image description here

If your language is not $\{a, b\}$, but $L = \sum \cup \{a, b\}$ then the $DFA$ is the same, just replace the $(a,b)$ by $ \sum^*$.

If you want the $DFA$, just apply Glushkov algorithm on the $NFA$.