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
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
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...
Which one of the following languages over the alphabet {0,1} is described by the regular expression...
Which one of the following languages over the alphabet {0,1} is described by the regular expression (0+1)* 0 (0+1)* 0 (0+1)* ? a.The set of all strings that begin and end with either 0 or 1 b.The set of all strings containing at most two zeros c.The set of all strings containing at least two zeros. d.The set of all strings containing the substring 00
Write the regular expression that will match the following string pattern descriptions. A space character at...
Write the regular expression that will match the following string pattern descriptions. A space character at the beginning of a line Upper case vowel one and more lines with a length of exactly 80 characters A single character that cannot be an alpha or a digit A dollar sign character ‘$’ at the end of the line
Are the following languages over {a, b} regular? If they are then prove it. If they...
Are the following languages over {a, b} regular? If they are then prove it. If they are not prove it with the Pumping Lemma {an bm | m != n, n >= 0} {w | w contains the substring ‘aaa’ once and only once } Clear concise details please, if the language is regular, provide a DFA/NFA along with the regular expression. Thank you. Will +1
Write a regular expression that generates each of the following language constructs: (1) String constants with...
Write a regular expression that generates each of the following language constructs: (1) String constants with the following specifications: A string constant consists of any sequence of characters enclosed by the quotation marks: “ and ” The sequence may be empty.​ The sequence cannot span multiple lines. Don’t worry about escape characters (assume that they won’t appear in the input). (2) Multiple-line comment in C, C++ and JAVA with the following specifications: The comment consists of any sequence of characters...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT