IAE Academy

ISRO CS 2025 Q.32: solution and answer

ISRO 2025 · CSQ.32 · 1 mark · MCQ

32. For the same input string, which of the following options is true in the case of ambiguous grammar?
(i) two different parse trees
(ii) two leftmost derivations
(iii) two rightmost derivations
(iv) leftmost and rightmost derivations are different
Which one is correct?

  1. (A)

    (i), (ii), (iii) are true; (iv) is false

  2. (B)

    (i) is true; (ii), (iii), (iv) are false

  3. (C)

    (i), (iv) are true; (ii), (iii) are false

  4. (D)

    (i) is false; (ii), (iii), (iv) are true

See the question in the paper

Answer and solution

ANSWER

Option (a): (i), (ii), (iii) are true and (iv) is false.

Official answer: ASource: ISRO's final answer key of 15 May 2026

  1. A grammar is ambiguous when some string in its language has more than one parse tree. So statement (i), two different parse trees for the same string, is true.

  2. Each parse tree corresponds to exactly one leftmost derivation. Two different trees for the same string therefore give two different leftmost derivations, so statement (ii) is true.

  3. Each parse tree also corresponds to exactly one rightmost derivation. Two different trees therefore give two different rightmost derivations, so statement (iii) is true.

  4. Statement (iv) does not hold in general for ambiguous grammars. Take , , , which is ambiguous on the string . Both trees have a leftmost derivation identical to their rightmost derivation, since each step has only one variable to expand. So the leftmost and rightmost derivations need not differ, and (iv) is not a property of ambiguity. It is also not a test for it, because the two derivations of one tree usually differ even in unambiguous grammars. So (iv) is false.

  5. So (i), (ii) and (iii) are true and (iv) is false, which is option (a). Option (b) wrongly denies (ii) and (iii). Option (c) wrongly denies (ii) and (iii) and wrongly accepts (iv). Option (d) denies (i), the defining property.

KEY IDEA

Parse trees, leftmost derivations and rightmost derivations correspond one to one. A string is ambiguous exactly when it has two parse trees, two leftmost derivations or two rightmost derivations.

WATCH OUT FOR

Treating "the leftmost and rightmost derivations are different" as a sign of ambiguity. That comparison is within one tree and says nothing about how many trees the string has.

From the ISRO CS 2025 paper. Every question of this paper · The full paper (PDF, ISRO) · All 6 ISRO CFG & PDA questions, with notes

More ISRO CFG & PDA questions