Computer Science EngineeringHardISRO SC
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?
- A. 4
- B. 3
- C. 2
- D. 6
Correct answer: B. 3
Each else may associate with any still-open if; counting derivations by span gives 3.
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
- 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)…
- Consider the grammar S -> aAd | bBd | aBe | bAe; A -> c; B -> c. The canonical LR(0) collection (with the augmented production S' -> start…