GateAI
Parsing

GATE CSE 2014 Set 2 · Q17

MCQ1 markEasy

Time

Consider the grammar defined by the following production rules, with two operators ∗* and ++ S→T∗PS \rightarrow T * P T→U∣T∗UT \rightarrow U \mid T * U P→Q+P∣QP \rightarrow Q + P \mid Q Q→IdQ \rightarrow Id U→IdU \rightarrow Id Which one of the following is TRUE?

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: B) + is right associative, while * is left associative

Parsing

To determine the associativity of operators from context-free grammar productions:

  1. **For operator ∗:∗∗Theproductionruleis*:** The production rule is T \rightarrow T * U \mid U.Sincethenon−terminal. Since the non-terminal Tappearsontheleftmostpositionontheright−handside( appears on the leftmost position on the right-hand side (T \rightarrow T * U$), the production is left-recursive. Therefore, the operator ∗* is left-associative.

  2. For operator $+: The production rule is P→Q+P∣QP \rightarrow Q + P \mid Q. Since the non-terminal PP appears on the rightmost position on the right-hand side (P→Q+PP \rightarrow Q + P), the production is right-recursive. Therefore, the operator ++ is right-associative.

Hence, ++ is right associative, while ∗* is left associative, which corresponds to option (B).

Try the question first, then check your work.

Think the official key or this write-up is wrong?

Report error or challenge

Examiner trap

The misconception this question tests

This Parsing previous year question is Q17 of the GATE CSE 2014 Set 2 paper. Find more GATE CSE PYQs on Parsing in Compiler Design, or browse all GATE CSE PYQs.

Free diagnostic

Where do you stand for GATE?

Take the 20-minute diagnostic: the 3 topics that cost you the most marks, and a rank range. Or sit 5 related Parsing PYQs now with no account.

One GATE CSE PYQ every morning

An official question by email at 7 AM IST, with a link to its verified solution. Unsubscribe in one click.

Parsing in GATE CSE

Parsing has 23 GATE CSE PYQs across 16 papers from 2012 to 2026. 5 of them are 1-mark MCQs like this one, and it is the only one in GATE CSE 2014 Set 2.

How GATE tests Parsing

More from GATE CSE 2014 Set 2

Share this solution

A plain-text card for WhatsApp or Telegram study groups.

GateAI solution cardGATE CSE 2014 Set 2 · Q17 · MCQ

Consider the grammar defined by the following production rules, with two operators * and + S → T * P T → U T * U P → Q + P Q Q → Id U → Id Which one of the following is TRUE?

Topic-wise GATE CS PYQs with verified steps

Independent practice explanation verified by the GateAI team. GATE is conducted by the IITs; question text follows the official paper.