Question

In: Computer Science

Construct a PDA that matches all strings in the language over {x,y} such that each string...

Construct a PDA that matches all strings in the language over {x,y} such that each string has at least twice as many y's as x's.

Below, give a short description of the set of strings associated with each state of your PDA.

Solutions

Expert Solution

sol:It is given that in each string there must be atleast twice the no of y's as many x's.

Examples-xyy,xxyy,xyxy,xyyy,yyx,yxy ... and many more strings of this pattern.

  

LOGIC:

i) For every x or y encountered on the input tape

1)If the stack is empty or top of the stack has same letter as that of the letter at the input tape -

i)Push 2 x's if the letter is x.

ii)Push only one y if the letter is y.

2)If the top of the stack has different letter as that of the letter at the input tape

i)Pop 2 y's if the top of the stack is y and and input tape has letter x.If the top of the stack has only one y then pop y and push one x.

ii)Pop one x if the top of the stack is x and input tape has letter y.

3)Final state-Stack must be either empty or it must have only y at the top of the stack.

Note:- delta(state,input,stack)=(newstate,new stack Symbol) for the below rules.

  


Related Solutions

Draw PDA transition diagram for the following language: The set of strings over the alphabet {x,...
Draw PDA transition diagram for the following language: The set of strings over the alphabet {x, y} where 2 * (# of x's) = 3 * (#y's) That is, if we let nx be the number of x's and ny be the number of y's, then the strings in these language are those where 2nx = 3ny Try to find a PDA that is as simple and elegant as possible (do not convert from CFG). ------------------------------------------------------------------------------------------------------------------ USE Notation between transition:...
14.6. Say that a string x overlaps a string y if there exist strings p, q,...
14.6. Say that a string x overlaps a string y if there exist strings p, q, r such that x = pq and y = qr, with q ̸= λ. For example, abcde overlaps cdefg, but does not overlap bcd or cdab. (a) Draw the overlap relation for the four strings of length 2 over the alphabet {a, b}. (b) Is overlap reflexive? Why or why not? (c) Is overlap symmetric? Why or why not? (d) Is overlap transitive? Why...
Construct a pda that accepts the language defined by the grammar S → aSSSab | λ...
Construct a pda that accepts the language defined by the grammar S → aSSSab | λ . This has already been answered using software with no explanation. I am not interested in the answer so much. I just want an explanation. or at least a step by step formula.
S is the language over S = {a, b, c, d, e} containing all strings that...
S is the language over S = {a, b, c, d, e} containing all strings that start with at least 2 a's, followed by any number of b's, followed by 5 c's, followed by an odd number of d's, followed by an even number of e's.  For example, S contains aaabbcccccdee, aaaacccccdddeeee, and so on.  Write S symbolically in the manner of section 6.1, problem # 12 a) - f).  Example 6.12 will also be helpful. bonus: How many strings in {000, 11}*...
Write a regular expression for the language of all strings over {a,b} in which every b...
Write a regular expression for the language of all strings over {a,b} in which every b is directly preceded by a, and may not be directly followed by more than two consecutive a symbols.
Write the following Python code: A string X is an anagram of string Y if X...
Write the following Python code: A string X is an anagram of string Y if X can be obtained by arranging all characters of Y in some order, without removing any characters and without adding new characters. For example, each of the strings "baba", "abab", "aabb" and "abba" is an anagram of "aabb", and strings "aaab", "aab" and "aabc" are not anagrams of "aabb". A set of strings is anagram-free if it contains no pair of strings which are anagrams...
Consider the language L over alphabets (a, b) that produces strings of the form aa* (a...
Consider the language L over alphabets (a, b) that produces strings of the form aa* (a + b) b*a. a) Construct a nondeterministic finite automata (NFA) for the language L given above. b) Construct a deterministic finite automaton (DFA) for the NFA you have constructed above.
4. Construct regular expressions for the following languages over the alphabet {a, b}: a. Strings that...
4. Construct regular expressions for the following languages over the alphabet {a, b}: a. Strings that do not begin with an “a”. b. Strings that contain both aa and bb as substrings. 5. Let ? = {? ?? ?? ? | ? > ? + ?}. a. List all strings of length 7. (use power notation: i.e. aabbbbaaaaaaaa is a2b 4a 8 ) b. Use the Pumping Lemma for Regular Languages to prove that L is not regular.
Prove the language of strings over {a, b} of the form (b^m)(a^n) , 0 ≤ m...
Prove the language of strings over {a, b} of the form (b^m)(a^n) , 0 ≤ m < n-2 isn’t regular. (I'm using the ^ notation but your free to make yours bman instead of (b^m)(a^n) ) Use the pumping lemma for regular languages.
Given the nested collection that maps each term to a set of strings   Return a string...
Given the nested collection that maps each term to a set of strings   Return a string of terms that are repeated in all the nested sets Given : {apple=[apple BALL carrot, ball !carrot! ,!Dog*&]} {apple=[apple BALL carrot, ball !carrot! ,!Dog*&], dog=[ball !carrot! ,!Dog*&]} Return: [ball !carrot! ,!Dog*&] Public static String common(Map<String, Set<Sting>> map) { }
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT