Find a state machine or a regex that accept the following language description

33 Views Asked by At

The alphabet of the language L is {a, b} and there has to be an even number of both a's and b's but no other restrictions apply.

I've been at this for over an hour, drawing state machines that lead me nowhere. This is a regular language right?

1

There are 1 best solutions below

1
On BEST ANSWER

Hint: Draw a state machine with four states:

  • $\boxed{S_{0,0}}$: This is the initial and only accepting state. If you're here, then there is an even number of both $a$'s and $b$'s.
  • $\boxed{S_{0,1}}$: If you're here, then there is an even number of $a$'s and an odd number of $b$'s.
  • $\boxed{S_{1,0}}$: If you're here, then there is an odd number of $a$'s and an even number of $b$'s.
  • $\boxed{S_{1,1}}$: If you're here, then there is an odd number of both $a$'s and $b$'s.

Can you figure out how to transition between states?