Quiz #2 Help Center

Learn more

Warning: The hard deadline has passed. You can attempt it, but you will not get credit for it. You are welcome to try it as a learning exercise.

Question 1

How many strings does the following grammar generate?
A→BB
B→CC
C→1∣2

Question 2

How many strings does the following grammar generate?
A→BB
B→CC
C→1∣2∣ϵ

Question 3

Which of the following grammar(s) produce regular languages?
[Choose all that apply]

Question 4

Considering the following grammar:
S→A
A→B∣C
B→(C)
C→B+C∣D
D→1∣0
Adding which of the following will cause the grammar to be left-recursive?
[Choose all that apply]

Question 5

Which of the following grammars correctly removes left-recursion from:
S→Aα∣δ
A→Sβ
[Choose all that apply]

Question 6

Consider the following grammar:
E→E∗E∣E+E∣(E)∣int
How many unique parse trees are there for the string 5∗3+(2∗7)+4?

Question 7

Using the grammar and string from the previous question (Question 6), which of the following rules are necessary to produce a unique parse tree for the string 5∗3+(2∗7)+4?
[Choose all that apply]

Question 8

[Choose all that apply]

Question 9

Consider following 4 grammars:
G1. S→aSb∣Sb∣b
G2. S→Sa∣Sb∣c
G3. S→SaS∣ϵ
G4. S→bT
      T→aT∣ϵ
Let n = the number of grammars where there exists a string that has at least two different left-most derivations;
m = the number of grammars where for any string, we only have one parse tree;
k = the number of grammars that can be used with a recursive descent parser
Choose the correct value for n,m and k.

Question 10

How many distinct strings and parse trees can be generated by the following grammar?
S→A1∣1B
A→10∣C∣ϵ
B→C1∣ϵ
C→0∣1

Question 11

Which of the following grammar(s) are unambiguous and recognize the same grammar as:
E→E+E∣E−E∣E∗E∣E/E∣int
[Choose all that apply]

Question 12

Let Tn be the string 0n1, to be matched with a recursive descent parser using the following grammar:
S -> A | B | 0S
A -> 0A | 0
B -> 1
Is the number of token comparisons needed to (successfully) match Tn:
    
You cannot submit your work until you agree to the Honor Code. Thanks!