Let be a language with the following alphabet : $\Sigma=\{a,b\}$
{ $w$ | $w$ does not contains $aa$ nor $bb$}
I know it can be graphed this way :
Can I write it as the following regular expression ?
$$(ab)^*+(ba)^*$$
No, you're missing $aba$ and $bab$ etc.
Obviously, we're looking for words of one of the forms
That translates to the RE
$(ab)^*a + (ab)^* + b(ab)^* + b(ab)^*a$
In CS, this is easier written as $a?(ba)^*b?$, when the $?$ modifier is available.