How many strings can this grammar generate?
X -> YY
Y -> ZZ
ZZ -> 0 | 1 | ε
Is there a shortcut to solving this rather than making all of the
possible combinations?
All the strings are ε 0 1 00 01 10 11 000 001 010 011 100 101 110 111 0000 0001 0010 0011 0100 0101 0110 0111 1000 1001 1010 1011 1100 1101 1110 1111 so, total number of strings = 31 Answer: 31
How many strings can this grammar generate? X -> YY Y -> ZZ ZZ -> 0...
Consider the following regular grammar with start symbol S and terminals {x, y}. S → xS S → yX S → yY X → xX X → yS Y → xY Y → λ List four strings, each of length less than 4, accepted by this grammar. (Include ε if it is accepted.) List four strings, each of length less than 4, not accepted by this grammar. (Include ε if it is not accepted.) In English, describe the language represented...
Construct context-free grammars that generate the given set of
strings. If the grammar has more than one variable, we will ask to
write a sentence describing what sets of strings expect each
variable in the grammar to generate. For example, if the grammar
was:
I could say "C generates binary strings of length one, E
generates (non-empty) even length binary strings, and O generates
odd length binary strings." It is also fine to use a regular
expression, rather than English,...
Construct context-free grammars that generate the given set of
strings. If the grammar has more than one variable, we will ask to
write a sentence describing what sets of strings expect each
variable in the grammar to generate. For example, if the grammar
was:
I could say "C generates binary strings of length one, E
generates (non-empty) even length binary strings, and O generates
odd length binary strings." It is also fine to use a regular
expression, rather than English,...
For each of the following, construct context-free grammars that generate the given set of strings. If your grammar has more than one variable, we will ask you to write a sentence describing what sets of strings you expect each variable in your grammar to generate. For example, if your grammar were: S → EO E → EE CC 0+ EC C+01 We would expect you to say “E generates (non-empty) even length binary strings; O generates odd length binary strings;...
How many distinct programs can the following grammar generate? S rightarrow a Z f xrightarrow b c | c b Y rightarrow de|cd Z rightarrow XY| YX a) 1 b) 4 c) 8 d) 24 e) An infinite number A5) Suppose you have a working compiler, properly modularized, that generates code for the MIPS instruction set. Which components would you have to change to adapt this compiler to generate code for another instruction set (say x86)? Select all correct answers....
Give a context-free grammar to generate each of the following: (a) {x#y | x, y ∈{0,1}* and |x| ≠ |y|} (b) The complement of the language {an bn | n ≥ 0}. (c) The set of boolean and arithmetic expressions. A boolean expression consists of a comparison of two arithmetic expressions using either of the two comparison operators < and ==. An arithmetic expression may involve numbers, identifiers, parentheses, and any of the four operators +, -, *, and /, with...
Consider the following BNF grammar: S ::= A x | B y A ::= B y | C w B ::= x | B w C ::= y Which of the following regular expressions describes the same set of strings as the grammar? 1. xwxy + xww∗y + ywx 2. xwx + xww∗y + yw 3. xw∗y + xwxyx + ywx 4. xwy + xw∗xyx + ywx 5. xw∗y + xw∗yx + ywx 6. none of the above 7. all...
1. Find the solution to the IVP : yy - x = 1, y (0) = 2 2. Find the general solution to the exact DE: e* dx – ydy = 0 3. Use ji = cos y to find an EXPLICIT solution to: (tan y)dx + xdy = 0
Solve the following:
1. x*y'-2*y-2*x^2*y 2. y xty/(x-5) 3. y'y/x, y(1)-2 4. yy+2*exp(2*x), y(0)=3 5. (1+x)*y+ysin(x), y(-pi/2)=0
1. x*y'-2*y-2*x^2*y 2. y xty/(x-5) 3. y'y/x, y(1)-2 4. yy+2*exp(2*x), y(0)=3 5. (1+x)*y+ysin(x), y(-pi/2)=0
Let A be the set of all bit strings of length 10. 1. How many bit strings of length 10 are there? How many bit strings of length 10 begin with 1101? How many bit strings of length 10 have exactly six 0's? How many bit strings of length 10 have equal numbers of O's and 1's? How many bit strings of length 10 have more O's than 1's? a. b. c. d. e.