GateAI
Lexical Analysis, Parsing and SDT

GATE CSE 2011 · Q27

MCQ2 marksMedium

Time

Consider two binary operators ‘↑\uparrow’ and ‘↓\downarrow’ with the precedence of operator ↓\downarrow being lower than that of the operator ↑\uparrow. Operator ↑\uparrow is right associative while operator ↓\downarrow is left associative. Which one of the following represents the parse tree for expression (7↓3↑4↑3↓2)(7 \downarrow 3 \uparrow 4 \uparrow 3 \downarrow 2)?

Select one answerSingle correct

Pick an option to check

Solution

Step-by-step verified solution

Official answer: B)

Lexical Analysis, Parsing and SDT

Given the expression: 7↓3↑4↑3↓27 \downarrow 3 \uparrow 4 \uparrow 3 \downarrow 2

  1. Precedence and Associativity Rules:

    • ↑\uparrow has higher precedence than ↓\downarrow, and is right-associative.

    • ↓\downarrow has lower precedence, and is left-associative.

  2. Parenthesization according to rules:

    • First, group the higher precedence operator ↑\uparrow from right to left:

      (3↑(4↑3))(3 \uparrow (4 \uparrow 3))
    • Next, group the lower precedence operator ↓\downarrow from left to right:

      ((7↓(3↑(4↑3)))↓2)((7 \downarrow (3 \uparrow (4 \uparrow 3))) \downarrow 2)
  3. Constructing the Parse Tree:

    • The operator evaluated last is at the root: the second ↓\downarrow.

    • Its left child represents (7↓(3↑(4↑3)))(7 \downarrow (3 \uparrow (4 \uparrow 3))) and its right child is 22.

    • For the subtree (7↓(3↑(4↑3)))(7 \downarrow (3 \uparrow (4 \uparrow 3))), the root is ↓\downarrow, with left child 77 and right child (3↑(4↑3))(3 \uparrow (4 \uparrow 3)).

    • For the subtree (3↑(4↑3))(3 \uparrow (4 \uparrow 3)), the root is ↑\uparrow, with left child 33 and right child (4↑3)(4 \uparrow 3).

    • For (4↑3)(4 \uparrow 3), the root is ↑\uparrow, with left child 44 and right child 33.

This structure corresponds exactly to tree (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 Lexical Analysis, Parsing and SDT previous year question is Q27 of the GATE CSE 2011 paper. Find more GATE CSE PYQs on Lexical Analysis, Parsing and SDT 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 Lexical Analysis, Parsing and SDT 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.

Lexical Analysis, Parsing and SDT in GATE CSE

Lexical Analysis, Parsing and SDT has 14 GATE CSE PYQs across 12 papers from 2011 to 2025. 2 of them are 2-mark MCQs like this one, and it is the only one in GATE CSE 2011.

How GATE tests Lexical Analysis, Parsing and SDT

More from GATE CSE 2011

Share this solution

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

GateAI solution cardGATE CSE 2011 · Q27 · MCQ

Consider two binary operators ‘ ’ and ‘ ’ with the precedence of operator being lower than that of the operator . Operator is right associative while operator is left associative. Which one of the following represents the parse tree for expression (7 3 4 3 2)?

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.