Construct a regular expression defining each of the following languages 1. The s
ID: 3619542 • Letter: C
Question
Construct a regular expression defining each of the following languages1. The set of all strings of even length beginning with ‘bab’
2. The set of all strings of odd lengths ending in ‘aaa’
3. The set of all strings containing even number of “ab”s
4. The set of all strings where every third symbol from left is an ‘a’. (consider strings shorter than 3 letters as well).
5. The set of all strings that do not begin with a double letter and do not end in ‘aba’
6. The set of all strings with total number of letters divisible by three
7. The set of all strings with no ‘aaa’
8. The set of all strings representing a binary number divisible by 4 or by 8
9. The set of all strings representing an odd binary number
10. The set of all strings representing a decimal number
divisible by 4
Explanation / Answer
1. The set of all strings of even length beginning with ‘bab’ RE = bab. (a +b) . (aa + ab +ba +bb)* 2. The set of all strings of odd lengths ending in ‘aaa’ (aa +ab +ba +bb)*. aaa 4. The set of all strings where every third symbol from left is an ‘a’. (consider strings shorter than 3 letters as well). RE = [a + b + ab + aa + bb +ba + (a+b).(a+b).a]. (a+b)* 6. The set of all strings with total number of letters divisible by three RE = (aaa + aab + aba + baa + abb + bab + bba + bbb)+ 8. The set of all strings representing a binary number divisible by 4 or by 8 RE = [ (1+0)*.00 + (1+0)*.000 ] 9. The set of all strings representing an odd binary number RE = (1 + 0)* . 1 10. The set of all strings representing a decimal number divisible by 4 RE = (1+0)*.00