Question

In: Computer Science

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:

for example x, a -> ε means read x, pop a and push ε

Solutions

Expert Solution

Given:

strings that can be generated by using this language must satisfy 2nx = 3ny

If nx = 3 and ny = 2 , 2* 3 = 3* 2, 6 = 6.

So the string For nx = 3 and ny = 2 the possibilities may be xxxyy, yyxxx, xyyxx, xxyyx, yxxxy, yxyxx, yxxyx, xyxyx, xyxxy, xxyxy.

Step 1:

If the y is first in string, push yy because nx is greater than ny .

if the x is first in string, push only x.

Step 2:

If the top of the stack is x and x is called, push xx. So, it cancels one x and adds one x to the stack.

If the top of the stack is y and y is called, push yy. So, it cancels one y and adds one y to the stack.

Step 3:

Suppose, if the top of the stack is x and y is called, pop x. (It gets cancels on each other)

Similarly if the top of the stack is y and x is called, pop y. (It gets cancels on each other)

step 4:

when string is finished and is called, Now the top of the stack must be Z0. The final state q1 is reached.


Related Solutions

Problem 4 (Sets defined inductively) [30 marks] Consider the set S of strings over the alphabet...
Problem 4 (Sets defined inductively) [30 marks] Consider the set S of strings over the alphabet {a, b} defined inductively as follows: • Base case: the empty word λ and the word a belong to S • Inductive rule: if ω is a string of S then both ω b and ω b a belong to S as well. 1. Prove that if a string ω belongs to S, then ω does not have two or more consecutive a’s. 2....
Draw a DFA for the following ( ∑ = {0,1}):                                 Set of all strings with.
Draw a DFA for the following ( ∑ = {0,1}):                                 Set of all strings with at most one consecutive pair of 1’s.
Using the pigeonhole theorem prove that any set of 220 10-character strings over the alphabet {a,b,c,d}...
Using the pigeonhole theorem prove that any set of 220 10-character strings over the alphabet {a,b,c,d} contains a pair of anagrams.
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.
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...
For the following data set: a) draw a scatter diagram, b) develop the estimation equation that...
For the following data set: a) draw a scatter diagram, b) develop the estimation equation that best describes the data, c) predict Y for X = 10, 15, 20. X 13 ,16 ,14 ,11 ,17 ,9 ,13 ,17 ,18, 12 Y 6.2 ,8.6 ,7.2 ,4.5 ,9.0 ,3.5 ,6.5 ,9.3 ,9.5, 5.7 Using the data given below, a) draw the scatterplot, b) develop the estimation equation that best describes the data, c) predict Y for X = 5, 6, 7. X...
Draw bifurication diagram of: (x^2-a)(x^2-4)
Draw bifurication diagram of: (x^2-a)(x^2-4)
Let L be the set of all languages over alphabet {0}. Show that L is uncountable,...
Let L be the set of all languages over alphabet {0}. Show that L is uncountable, using a proof by diagonalization.
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.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT