Question

In: Computer Science

1. All questions assume the alphabet Σ = { a , b }. a) Give a...

1. All questions assume the alphabet Σ = { a , b }.

a) Give a regular expression representing the language of all strings containing abab as a substring.

b) Give a regular expression representing the language of all strings with an even number of a's or an odd number of b's, such as abab or baabaab.

c) Give a regular expression representing the language of all strings of the form ambn, where m is even and n is odd. Observe that all the a's come before all the b's, which is different than the previous 2 questions. Sample strings are aab, aabbb, aaaab, and bbbbb. (Remember that 0 is even).

d) List the first 10 strings in canonical order of the language in question b above (even number of a's or odd number of b's, where the a's and b's can occur in any order).

e) List the first 10 strings in canonical order of the language in question c above (ambn).

Solutions

Expert Solution

1. [ab]*abab[ab]* - Any number of valid characters before and after 'abab'

2. b*[ab*ab*]* | a*ba*[ba*ba*]* The sub-expression on the left is for even number of 'a's and the one on the right is for odd number of 'b's.

b*[ab*ab*]* - represents any number of 'b's followed by even number (including 0, 2, 4 etc) of 'a's. The 'a's are separated from each other by zero or more 'b' on both sides.

The expression for odd 'b's is very similar except that there is a mandatory 'b', with any number of 'a's on each side; this is then followed by an expression representing an even number of 'b's.

3. [aa]*b[bb]* - this is a pair of 'a's repeated any number of times - to provide an even count of 'a's followed by one b and then an even number of 'b's - so that we totally have an odd number of 'b's.

4. 10 basic valid strings are b, aba, baa, ababb, babab, abababa, bbabab, aabaababa, bbabbabb, aabaababa - not sure about canonical order though.

5. 10 valid strings are b, aab, aabbb, aaaab, aaaabbb, aaaaaab, aaaaaabbb, aaaabbbbb, aaaaaabbbbb, aaaaaaaab - again, not sure about canonical order, you will have to excuse that. Could not find ANY online references to canonical forms for regular expression strings.


Related Solutions

Automata Question. Over the alphabet Σ = {a, b}: 1) Give a DFA, M1, that accepts...
Automata Question. Over the alphabet Σ = {a, b}: 1) Give a DFA, M1, that accepts a Language L1 = { w | w has exactly 2 a’s } 2) Give a DFA, M2, that accepts a Language L2 = { w | w has at least 2 b’s } 3) Give acceptor for L1 intersection L2 4) Give acceptor for L1 - L2
1. Prove the language L is not regular, over the alphabet Σ = {a, b}. L...
1. Prove the language L is not regular, over the alphabet Σ = {a, b}. L = { aib2i : i > 0} 2) Prove the language M is not regular, over the alphabet Σ = {a, b}. M = { wwR : w is an element of Σ* i.e. w is any string, and wR means the string w written in reverse}. In other words, language M is even-length palindromes.
3. Are the following languages A and B over the alphabet Σ = {a, b, c,...
3. Are the following languages A and B over the alphabet Σ = {a, b, c, d} regular or nonregular? • For a language that is regular, give a regular expression that defines it. • For a nonregular language, using the pumping lemma prove that it is not regular. (a) A = {d 2j+1c k+1 | j ≥ k ≥ 0} · {c r+2b 2s+3 | r ≥ 0 and s ≥ 0} (b) B = {a 2j+2b k+3c j+1...
Theory of computation: Consider the alphanumeric alphabet Σ = {a, b, . . . , z,...
Theory of computation: Consider the alphanumeric alphabet Σ = {a, b, . . . , z, A, B, . . . , Z, 0, 1, . . . , 9} and let L be the language of all regular expressions over Σ: L = {w ∈ Σ ∪ {∅,(,), ∪, ·, * }* | w is a syntactically legal regular expression over Σ} Give an unambiguous context-free grammar that generates L. The grammar should use the following precedence levels, from...
Given an alphabet Σ, what are the languages L over Σ for which L ∗ is...
Given an alphabet Σ, what are the languages L over Σ for which L ∗ is finite? How many such languages exist?
Consider the language L1 over alphabet Σ = { 0, 1 } where the production rules...
Consider the language L1 over alphabet Σ = { 0, 1 } where the production rules for L1 are as follows: S → TT S → U T → 0T T → T0 T→ 1 U → 0U00 U → 1 Q → λ P → QU Transform this grammar into Chomsky Normal Form, consistent with the CNF specification in the Quick Reference, and using only Variables { S, T, U, V, W, X }. Implement that CNF grammar in...
Show that for all σ ∈ Sn we have sgn(σ) = sgn(σ−1). Does σ = (1,2,3,5,4)−1...
Show that for all σ ∈ Sn we have sgn(σ) = sgn(σ−1). Does σ = (1,2,3,5,4)−1 ∈ S13 belong to the alternating group A13? Justify your answer
READ ALL QUESTIONS AND ANSWERS THROUGHLY 1. Assume that there is no capital inflow outflow in...
READ ALL QUESTIONS AND ANSWERS THROUGHLY 1. Assume that there is no capital inflow outflow in the market for loanable funds, and that the federal government decides to increase borrowing in order to pay for some of their expenditire (i.e. G^). How would this policy change affect the market for loanable funds? A. increase in interest rates, increase in the quanity of loanable funds B. increase in interest rates, decreases in the quanity of loanable funds C. decrease in interest...
The questions below are all based on the following assumptions: 1. Assume you are the CFO...
The questions below are all based on the following assumptions: 1. Assume you are the CFO of a publicly traded corporation 2. Assume you are seeking to borrow and/or raise some money 3. Assume you have two options: Option A: Sign with a bank for a 30-yr $100,000 bank loan at 3% APR Option B: Issue a 30-yr $100,000 bond with a 3% coupon rate Question 1) Which of the two options has the higher duration? Question 2) In which...
Answer All Questions. 1) All of the following are strong electrolytes EXCEPT : a. Mg(HCO3)2 b....
Answer All Questions. 1) All of the following are strong electrolytes EXCEPT : a. Mg(HCO3)2 b. H2S c. KNO2 d. Li2SO4 e. HClO4 2) Look at the following balanced equation: 2 C4H10 + 13 02 —> 8 CO2 + 10 H2O If 18.5 grams of C4H10 reacts with 52.4 g O2, what is the theoretical yeild of CO2 in grams? 3) A 7.56 g sample of acetic acid, HC2H3O2, is dissolved in water. What is the molarity of Ba(OH)2 solution...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT