Consider the grammar G with start symbol A and production: A → A # A | 1 Which…
Consider the grammar G with start symbol A and production:
A → A # A | 1
Which of the following options is not correct?
Answer: C. Every string generated by the grammar has more than one parse tree — Correct answer: Every string generated by the grammar has more than one parse tree. The statement is not correct because some generated strings have a unique…
- A.
The string "1#1" has one parse tree / leftmost derivation
- B.
The string "1#1#1" has two parse trees / leftmost derivations
- C.
Every string generated by the grammar has more than one parse tree
- D.
Grammar G is ambiguous
Attempted by 68 students.
Show answer & explanation
Correct answer: C
Correct answer: Every string generated by the grammar has more than one parse tree.
The statement is not correct because some generated strings have a unique parse tree. For example, "1" and "1#1" each have only one parse tree.
However, the grammar is still ambiguous. The string "1#1#1" can be parsed in two ways:
1. (1#1)#1
2. 1#(1#1)
So option 4 is true, option 2 is true, and option 1 is true. The only incorrect statement is option 3.