Last updated on:May 27th, 2018,

Regular expression (RE) for the language of all those strings starting with aa and ending with ba

What is the regular expression (RE) for the language of all those strings starting with aa and ending with ba? Defined over ∑={a,b}

Accepted Strings: 

These all strings are the part of the language so should be accepted by regular expression;

Example strings = {aaba, aaaba, aabba, aaabba, aababa,………}and all other strings that can start with aa and end with ba.

Rejected Strings:

These all strings are not part of the language so should be rejected by regular expression.

Example strings = {a, b, ab, ba, aab, bba, abba,……………..} and all other strings that can’t start with aa or can’t end with ba.

R.E = aa (a+b)*ba

Part 1Part 2Part 3
aa(a+b)*ba

 

 

 

 

Explanation:

Part 1:

We are bounding the machine to always get aa when the machine starts generating any string from the regular expression. aa is the must for the machine to read at the start.

Part 2:

We are bounding the machine to always get (a+b)*  when the machine starts generating any string from the regular expression. aa is the must for a machine to read at the start and then machine reads (a+b)*

Plus symbol(+) representing the or(option). It means that machine can read a or machine can read b multiple times. * represents that machine can read multiple times a or b

Part 3: 

We are bounding the machine to always ba at the last.  When machine generates a string from the R.E, then machine enter first in part 1, then in part 2 and finally, machine enter in part 3 and must read ba.

Practice:

Now lets practice that how the string can be generated. Please follow the colors;

R.E = aa (a+b)*ba

Strings: aaba, aaaba, aabba, aaaaba, aabbba, aaaababba, aabbaabababa,…………..

Topic Covered 

Rregular expression (RE) for the language of all those strings starting with aa and ending with b.
  List of All Regular Expression examples : Click Here 
.

0Shares

1 thought on “Regular expression (RE) for the language of all those strings starting with aa and ending with ba

Leave a Reply

Your email address will not be published.