Computer Science EngineeringHardISRO SC
The grammar S -> aS | Sa | a is ambiguous. How many parse trees does a^5 have?
- A. 17
- B. 15
- C. 16
- D. 5
Correct answer: C. 16
Counting by whether the root uses aS, Sa, or (for n=1) a: T(1)=1, T(n)=2T(n-1) giving 16.
Practise more Theory of Computation, Compilers & Digital Logic (ISRO CS) questionsTheory of Computation, Compilers & Digital Logic (ISRO CS): notes and key points
More Theory of Computation, Compilers & Digital Logic (ISRO CS) questions
- For the dangling-else grammar S -> i S e S | i S | a (i = if, e = else, a = other statement), how many parse trees derive iiiaeaea?
- The CYK algorithm runs on a string of length 10 with a grammar in Chomsky normal form. Counting each (cell, split point) pair as one step…
- A grammar in Chomsky normal form derives a string of length 9. The number of derivation steps (rule applications) in any derivation is
- Consider the grammar E -> E+T | T; T -> TF | F; F -> (E) | id. The canonical LR(0) collection (with the augmented production S' -> start…
- For the grammar E -> E+T | T; T -> TF | F; F -> (E) | id, how many total LR(0) items (all dotted positions over all productions, excluding…
- Consider the grammar S -> AB; A -> aA | a; B -> bB | b. The canonical LR(0) collection (with the augmented production S' -> start symbol)…