2) Write a CFG for L = {w | w has an equal number of a's and b's } over the alphabet {a,b,c}.
Grammar: ----------- S -> aB | bA | cS |A -> aS | bAA | cA B -> bS | aBB | cB
I have below questions with answer! what if we get different question: Write a CFG without empty rules that generates the language: L = strings from (a ∪ b)*c* where the number of a's and b's together is equal to the number of c's. Answer: S → Asc | ε A → a | b ================================================== Write a CFG without empty rules that generates the language: L = strings from (ab ∪ cb)*c* where the number of a's and b's...
Theory of Computation - Push Down Automata (PDA) and Context
Free Grammars (CFG)
Problem 1. From a language description to a PDA Show state diagrams of PDAs for the following languages: a. The set of strings over the alphabet fa, b) with twice as many a's as b's. Hint: in class, we showed a PDA when the number of as is the same as the number of bs, based on the idea of a counter. + Can we use a...
Write a right-linear CFG for the regular languages: (∑={0,1}) a. L = { w | w is a binary string which starts and ends with the same symbol} b. L = { w | w is a binary string with at least three 0’s } c. L = { w | w is a binary string with odd number of 0’s and even number of 1’s}
Consider the language L _ {w E {a,b)' : the longest run of a's in u, is longer than any run of b's in w} For example, abbbbaabbbaaaaa E L because the longest run of b's in it has length four, while the longest run of a's has length six. Prove that L is not context-free.
Design a CFG (Context Free Grammar) for each of the following languages: L4 = {w | w does not have exactly as many a's as b's}.
Give a Context Free Grammar (CFG) for the following language: L = { w | the number of a’s and the number of b’s in w are equal, ∑= {a, b} }
1) Assume ∑ = {a, b}, construct a DFA to recognize: {w | number of a's in w ≥ 2 and number of b's in w ≤ 1}. (seven states) 2) Assume ∑ = {a, b}, construct a DFA to recognize: {w || w | ≥ 2, second to the last symbol of w is b}. (four states) 3) Write a regular expression for: All bit strings that contain at least three 1's.
1. Construct a DFSM to accept the language: L = {w € {a,b}*: w contains at least 3 a's and no more than 3 b's} 2. Let acgt} and let L be the language of strings consisting of repeated copies of the pairs at, ta, cg, gc. Construct both a DFSM to accept the language and a regular expression that represents the language 3. Let a,b. For a string w E ', let W denote the string w with the...
Show L = { w | w is an element of {a, b, c, d, e, f}* such that the number of a's + number of b's = number of c's + number of d's = number of e's + number of f's } is not context-free
Input alphabet {a,b 1. write the CFG for the language of palindromes (5 points) 2. Convert this into PDA (state the accepting condition) (10 points) . Write a PDA for this language that satisfies the conditions required to convert it into CFG (5 points) 4. Convert the PDA from Q3 into CFG (10 points)
Input alphabet {a,b 1. write the CFG for the language of palindromes (5 points) 2. Convert this into PDA (state the accepting condition) (10 points) ....