Question

Write the regular expression for the following sets (4.5) 4.1 All strings over {a,b} that are...

  1. Write the regular expression for the following sets (4.5)

4.1 All strings over {a,b} that are odd in length

4.2 All strings over {a,b} whose length is not a multiple of 3

4.3 All strings over a,b that start with aa and end with bb

Homework Answers

Answer #1

1)
((a+b)(a+b))*(a+b)

2)
((a+b)(a+b)(a+b))*((a+b) + ((a+b)(a+b)))

3)
aa(a+b)*bb

Explanation:
-------------
(a+b) matches a single letter a or b.
(a+b)(a+b) matches two letters (aa, ab, ba, or bb)
((a+b)(a+b))* matches even number of letters
so, ((a+b)(a+b))*(a+b) matches odd number of letters

((a+b)(a+b)(a+b))* matches letters of multiple of 3
and then ((a+b) + ((a+b)(a+b))) matches either 1 or two letters to make it match any string with length of not a multiple of 3.
Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Problem 5 Regular Expressions. a) Define a regular expression for all strings of odd length, over...
Problem 5 Regular Expressions. a) Define a regular expression for all strings of odd length, over the alphabet of {0}. b) Define a regular expression for identifiers over the alphabet of {A,B,C,a,b,c,0,1,2,3,4,5,6,7,8,9}, such that an identifier must begin with an alphabetic character and must contain at least one numeric character. c) Try to modify the definition above so that identifiers still begin with an alphabetic character, but after that, it must contain at least one numeric, at least one lower-case...
For each of the following regular expressions, give 2 examples of strings that are in the...
For each of the following regular expressions, give 2 examples of strings that are in the language described by the regular expression, and 2 examples of strings that are not in that language. In all cases the alphabet is {a,b}. ab*ba* (a ∪ ε)b* (a ∪ b)ε*(aa ∪ bb)
For each of the following regular expressions, give 2 examples of strings that are in the...
For each of the following regular expressions, give 2 examples of strings that are in the language described by the regular expression, and 2 examples of strings that are not in that language. In all cases the alphabet is {a, b}. ab*ba* (a ∪ ε)b* (a ∪ b)ε*(aa ∪ bb)
Find a regular expression to describe: The set of all strings over the alphabet {a, b,...
Find a regular expression to describe: The set of all strings over the alphabet {a, b, c, d} that contain exactly one a and exactly one b So, for example, the following strings are in this language: ab, ba, cccbad, acbd, cabddddd, ddbdddacccc and the following strings are NOT in this language: a, ccbc, acbcaaacba, acacac, bcbbbbbca, aca, c, d, b
Give a regular expression for the set of strings over {a, b, c} such that the...
Give a regular expression for the set of strings over {a, b, c} such that the sum of the number of a’s and the number of b’s is equal to 3.
Show a regular expression representing the described set: a). The set of strings of odd length...
Show a regular expression representing the described set: a). The set of strings of odd length over {s,t,r,i,n,g} containing exactly 3 n's.
Write a formal grammar that generates all strings of odd length over Σ = {a, b}.
Write a formal grammar that generates all strings of odd length over Σ = {a, b}.
Give a regular expression for the set of all strings on the alphabet {0,1} with no...
Give a regular expression for the set of all strings on the alphabet {0,1} with no runs of length greater than 3(for example, no substrings 0^i or 1^i with i > 3)
Give a regular expression for each of the following sets: a) set of all string of...
Give a regular expression for each of the following sets: a) set of all string of 0s and 1s beginning with 0 and end with 1. b) set of all string of 0s and 1s having an odd number of 0s. d) set of all string of 0s and 1s containing at least one 0. e) set of all string of a's and b's where each a is followed by two b's. f) set of all string of 0s and...
Consider the regular expression ? = b(ba U aab)*(b U a*). In lexicographical order (shorter strings...
Consider the regular expression ? = b(ba U aab)*(b U a*). In lexicographical order (shorter strings before longer strings, alphabetical order for strings of the same length), give the 8 shortest strings in the language generated by ?.