Question: a ) Give a context - free grammar for the language A of strings over { x , y } that are formed from a

a) Give a context-free grammar for the language A of strings over {x,y} that are formed from a sequence of x's followed by a sequence of y' s, such that there are always the same number of x's as y's or else one more x than y. Examples: ,x,xy,y, xxyy. Is your grammar ambiguous? Why or why not?
b) Give a context-free grammar for the language B of strings over {x,y} that are formed from at most one occurrence of y and any number of x's. Examples: ,y,x,xy,yx,,xyx,y,x. Is your grammar ambiguous? Why or why not?
c) Give a context-free grammar for the language C over {x,y} in which the string is a concatenation for two strings such that the first string is in A(from Part a) and the second string is in B(from Part b). Is your grammar ambiguous? Why or why not
d) Draw all possible parse trees for the strings xxxyyy and xxyyxx using your grammar from Part c.
 a) Give a context-free grammar for the language A of strings

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!