Question discussion

Which of the following grammars is ambiguous?

2550Medium DSSSB TGT Computer Science 0 replies

Which of the following grammars is ambiguous?

  • AS → aSb | ε
  • BE → E + T | T, T → id
  • CE → E + E | E * E | id
  • DS → aS | a
Correct answer: C

Explanation

The string id + id * id has two different parse trees under E → E + E | E * E | id, so the grammar is ambiguous, while the other grammars give a unique parse tree for every string.

Discussion 0

Nobody has replied yet. Start the discussion!