148k views
4 votes
Let Σ= {a, b}. Construct a regular expression defining each of the following languages over Σ.

The language of all words in which the total number of b's is divisible by 3 no matter how they are distributed, such as bbabbaabab.

1 Answer

3 votes

Final answer:

To construct a regular expression for the language of all words in which the total number of 'b's is divisible by 3, we can use the expression (a^*ba^*ba^*ba^*)^*.

Step-by-step explanation:

To construct a regular expression for the given language, we need to consider all possible combinations of 'a' and 'b' in a word where the total number of 'b's is divisible by 3. Let's break it down step by step:

  1. Starting with the base case, let's first consider the words with 0 'b's. This can be represented as '(a^*ba^*)^*', where 'a^*' matches any number (including 0) of 'a's.
  2. Next, let's consider the words with 3 'b's. This can be represented as '(a^*ba^*ba^*ba^*)^*'.
  3. Similarly, we can generalize the expression for any number of 'b's divisible by 3 as (a^*ba^*ba^*ba^*)^*.

So, the regular expression for the language of all words in which the total number of 'b's is divisible by 3 is:

(a^*ba^*ba^*ba^*)^*

User Nfort
by
7.2k points