Question

Find a regular expression for the following language L= {w∈{a,b}*:(na(w)-nb(w)mod)3=1} please show explanation and steps

Find a regular expression for the following language

L= {w∈{a,b}*:(na(w)-nb(w)mod)3=1}

please show explanation and steps

Homework Answers

Answer #1

Here, we have given the Language as:-

L = {w {a,b}* : (na(w) – nb(w) mod)3 =1

The above language means that in a string we have to count the number of “a” and number of “b”, then take a difference between them and then divide it by 3, after dividing we should get a remainder as 1.

Or we can say that, the difference between the number of “a” and the number of “b” should be (multiple of 3 + 1), then only we can get remainder as 1.

For example:-

The regular expression should follow these values:

a =

b =

(a-b)|3 =

1

0

(1-0)|3 = 1

2

1

(2-1)|3 = 1

3

2

(3-2)|3 = 1

4

0

(4-0)|3 = 1

7

0,3

(7-0)|3 = 1 or (7-3)|3 = 1

10

0,3,7

(10-7)|3 = 1 or (10-3)|3 = 1 or (10 -0)|3 =1

Like that we can take the number of "a" and number of "b". And so on....

Now let’s consider the strings that will satisfy the above language.

Let’s take for "a" only:-

L = {λ, a, aaaa, aaaaaaa, aaaaaaaaaa, aaaaaaaaaaaaa,........}

If we take λ then, yes it can be accepted by the language as λ is constant. So we can get 1 as a remainder after dividing a constant by 3.

Next, we can take 4 times "a" as "aaaa". (Here number of "a" is 4 and number of "b" is 0, so we get 4 after subtracting 4-0 = 4 and when we divide 4 by 3 we will get 1 as a remainder.

similarly we can take 7 times "a" as "aaaaaaa" , then 9 times "a" and so on....Means if we take number of "a" as one more than the multiple of three then that string will be accepted by the language.

So, we can say that for “a” there is a cycle of 3 “a”.(Here, according to string we should take a cycle of 4 "a", but we will take a cycle of 3 only why? i will explain this later.)

So if we design a DFA for letter "a" only, our starting state will be q0 and the final state will be q1. So, if we start counting from q0 , then after moving one cycle the number of "a" which is multiple of 3 will come back to q0 and then we have to add one more "a" (as we have number of "a" one more than the multiple of 3)  so it moves to the final state q1.

Now, we will check for number of "b".

L = {a, aaaa, aaaaaaa, aaaaaaaaaa, aab, aaabb, aaaabbb, aaaaaaabbb, aaaaaaaaaabbb, aaaaaaaaaabbbbbb,.......}

So, if we take “b” as a multiple of three then it will be accepted by language. But in DFA we will take “b” as a reverse direction of “a” because we have to cancel “a” and “b” by subtracting and then divide it by 3 to get a remainder 1 which is lesser value than “a” and “b”.

Now our final DFA will be:-

Then, we will reduce the step to obtain the following NFA:-

Finally the regular expression is ((ba)* (a + bb) ) ((ab)* + (b + aa) (ba)* (a + bb))*.

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
What is the regular expression for the language L={w| w starts with 1 and has odd...
What is the regular expression for the language L={w| w starts with 1 and has odd length}? The alphabet of the language is {0, 1};
3. Consider the following “theorem". If L is a regular language then ∀ words w ∈...
3. Consider the following “theorem". If L is a regular language then ∀ words w ∈ L where |w| > 1 ∃ an expression w = xyz where (a) ∀i≥0.xyiz∈L (b) |y| ≥ 1 Explain whether this is a (true) theorem or not ( the question want us to explain why this theorem does not work alone)
Construct a deterministic PDA for L = {w ∈ {a, b}* : na (w) = nb...
Construct a deterministic PDA for L = {w ∈ {a, b}* : na (w) = nb (w)}
Given a language L, etc. Show that the language L is a regular language. To show...
Given a language L, etc. Show that the language L is a regular language. To show that the language L is a regular language - find/design a dfa that recognizes the language L. Given a regular expression r, etc. What is the language L, L = L(r)? L(r) is the set of all strings etc.
Let Σ = {0, 1}. Give a regular expression that expresses the language {w | w...
Let Σ = {0, 1}. Give a regular expression that expresses the language {w | w contains exactly two 0s}.
Are the following languages over {a, b} regular? If they are then prove it. If they...
Are the following languages over {a, b} regular? If they are then prove it. If they are not prove it with the Pumping Lemma {an bm | m != n, n >= 0} {w | w contains the substring ‘aaa’ once and only once } Clear concise details please, if the language is regular, provide a DFA/NFA along with the regular expression. Thank you. Will +1
Construct an NFA for the following language: L = {w ∈ {a,b}∗ : every a is...
Construct an NFA for the following language: L = {w ∈ {a,b}∗ : every a is immediately followed by at most 2 b's}
Let L be a regular language over {0, 1}. Show how we can use the previous...
Let L be a regular language over {0, 1}. Show how we can use the previous result to show that in order to determine whether or not L is empty, we need only test at most 2n − 1 strings.
Find a regular expression to describe: The set of all strings over the alphabet {a, b,...
Find a regular expression to describe: The set of all strings over the alphabet {a, b, c, d} that contain exactly one a and exactly one b So, for example, the following strings are in this language: ab, ba, cccbad, acbd, cabddddd, ddbdddacccc and the following strings are NOT in this language: a, ccbc, acbcaaacba, acacac, bcbbbbbca, aca, c, d, b
6) please show steps and explanation. a)Suppose r(t) = < cos(3t), sin(3t),4t >. Find the equation...
6) please show steps and explanation. a)Suppose r(t) = < cos(3t), sin(3t),4t >. Find the equation of the tangent line to r(t) at the point (-1, 0, 4pi). b) Find a vector orthogonal to the plane through the points P (1, 1, 1), Q(2, 0, 3), and R(1, 1, 2) and the area of the triangle PQR.