You are on page 1of 1

Assignment II

1. Write a RE for Identifiers formed as follows: an identifier consists of one or more


letters (a‐z and A‐Z), digits (0‐9) and underscores (_). An identifier must begin with
a letter and may not end with an underscore. The answer is below it:
[a-z A-Z][A-zA-Z0-9]{0-20} 
And also it forgot about _ (Underline) and that must be [a-z A-Z_][a-zA-Z0-9_]{0-20}
2. Obtain the regular expressions for the languages given by:
(a) L1 = {a2nb 2m+1|n>0, M>0} : look at the answer bellow the following in (i) & (ii)
i. (a+b)*(∈ + a) + (a+b)*(bb)
ii. (aa)*b(bb)*
(b) L2 = {a, bb, aa, abb, ba, bbb, . . . } The answer is below the following
(A+BB)*
3. Write a regular expression for all strings of a’s and b’s which contains the substring
abba?
The set of strings over {a, b} that contains the substrings aa or bb
(a+b)*aa(a+b)* + (a+b)*bb(a+b)*
4. Obtain the regular expressions for the languages given by
(c) L 3 = { w ∈ {0, 1}* | w has no pair of consecutive zeros} : The answer is bellow the following
+ 01)* (0 + λ)

(d) L4 = {Strings of 0's and 1's ending in 00}


R = 1 (0+1)* 0  

Note: (a)& (b) i.e L1 & L2 are done in Question No.(2)

You might also like