1

I am new to theoretical cs and am working through it slowly. I have completed a simple question and was wondering if my answer is correct or not. Thank you kindly for any feedback.

The question is: Given the alphabet $\{a, b\}$ Construct a regular expression that defines the language $M$ containing all words beginning with exactly one $a$ or exactly one $b$. Words in $M$ are at least of length $1$. Words in $M$ can begin and end with the same letter substring or begin and end with different letter substrings.

My answer is: $( a( b( a + b)^*)^*) + (b ( a (a + b)^*)^*)$

Thank you.

J.-E. Pin
  • 6,129
  • 18
  • 36

1 Answers1

1

Setting $A = a + b$, you could write $M$ as $A + abA^* + baA^*$ or as $A + (ab +ba)A^*$. This avoids the nested star of your answer.

J.-E. Pin
  • 6,129
  • 18
  • 36