I've been battling the following two questions for more than a day today.
Write a regular expression (comprised of {a, b}) that contain at least two b and do not contain abb.
Write a regular expression (comprised of {a, b}) that contain abba and do not contain baa.
For the first part I wrote a basic one to start off with that doesn't handle the must two-b:
b* OR a* OR (a+ AND b)* OR a*
I ran a few "truth tables" inputs over it and it seems ok. But the moment I add the requirement, things go haywire. Mostly because when pushing in those "b"s, you can suddenly use the OR to break things up.
Same thing on the second one....
Any help would be greatly appreciated!
Norah
You have
b*(a+b)*a*that matches words withoutabb.Split the string on its first
a. On the left it will haveb*and on the right it will have(a+b)*a*. The twobcan be both on left, one on left and one on right or both on right side. That's three cases. In each case two things of the formx*have to turn intoxx*.bbb*(a+b)*a*bb*(a+b)(a+b)*a*b*(a+b)(a+b)(a+b)*a*