Question

A canonical set of items is given below

S→L.>RS \to L . > R
Q→R.Q \to R .

On input symbol << the set has

Choose one option
Official answer and solution
Official answer
D
From
Official GATE 2014 answer key

Solution

Examine the actions enabled in the given canonical LR item set for input symbol '<'.

The canonical set of items is:

  1. S→L.>RS \to L . > R
  2. Q→R.Q \to R .

Examine possible actions on input symbol '<<':

  1. Shift action:

    • In S→L.>RS \to L . > R, the dot is immediately followed by the terminal symbol '>>'.
    • A shift action in this item is valid only on input symbol '>>', which transitions to a state containing S→L>.RS \to L > . R.
    • There is no shift action on '<<'.
  2. Reduce action:

    • In Q→R.Q \to R ., the dot is at the end of the production, representing a reduction by Q→RQ \to R.
    • Even if '<<' is in FOLLOW(Q)\text{FOLLOW}(Q) so that a reduction action is placed under '<<', there is only one reduce item.
  3. Conflicts on '<<':

    • Shift-reduce conflict requires at least one shift and at least one reduce on the same symbol '<<'. Since there is no shift on '<<', no shift-reduce conflict exists.
    • Reduce-reduce conflict requires two distinct reduce items to reduce on '<<'. Since there is only one reduce item in the set, no reduce-reduce conflict can exist.

Therefore, on input symbol '<<', the set has neither a shift-reduce nor a reduce-reduce conflict.

Final answer

D

Common trap

Assuming the item shifts on any comparison operator rather than the specific symbol '>>' after the dot.

The answer is the one in the official GATE answer key. The solution is this site's own explanation.

Source

Paper
GATE 2014 Computer Science and Information Technology (CS) Session 1
Question
44 of 65, printed as CS Q.34
Section
Computer Science and Information Technology

Report an error in this question

GATE questions are the work of the organising institutes. This site is independent and is not affiliated with them.