Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write regular expressions for each of the following languages. a, = { a, b, c }

ID: 3813667 • Letter: W

Question

Write regular expressions for each of the following languages.

a, = { a, b, c } All strings that …

b, contain no more than two ‘c’s

c, start and end with the same character

d, have ‘c’s only in the middle (not at either end), and there is at least one ‘c’

e, contain ‘abc’

f, do not contain ‘aa’

g, contain only ‘b’s and are not empty

h, contain exactly two ‘a’s and exactly one ‘c’

i, have all ‘a’s (if any) before all ‘c’s (if any)

l, have ‘a’ in all even positions

k, begin with three matching characters (i.e., aaa…, bbb…, or ccc…)

Explanation / Answer

Ans : b .not more than 2 c's = (a* b* c a* b*c a* b* ) .....[* indicates occurances of one or many times for a character]

As c shouldnt be more than two times and there is no restriction on other characters .

c. start and end with the same charcter = ^abc$ .....[ ^ and $ indicates start and end with same charcters)

e. contain abc = a*b*c*(abc) ......... [the string should contain abc ]

h. exactly 2 a's and 1 c = aab*c .........(exactly 2 a's and one c no restriction on occurance of 'b').

  

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Chat Now And Get Quote