GATE CSE 2018 Q48: Precedence and associativity of the dollar and hash operators from a parse tree
- Compiler Design
- 2 marks
- MCQ
- −2/3 if wrong
Syllabus topic: Lexical analysis, parsing and syntax-directed translation
Question
Consider the following parse tree for the expression , involving two binary operators and .

Which one of the following is correct for the given parse tree?
Try it: multiple choice: exactly one correct option
Show answer and explanation
Answer: A (official GATE 2018 final answer key)
Concept used: Operators lower in a parse tree bind tighter (higher precedence); a left-leaning chain of the same operator means left associativity, a right-leaning chain means right associativity.
First step: Read the grouping off the tree: see whether the nodes sit below the nodes, and in which direction chains of and of nest.
Full step-by-step solution
Loading…
Answer from the official final answer key. Found a mistake? Use Report issue and we will fix it.
More questions on Lexical analysis, parsing and syntax-directed translation
Every PYQ on this topic →Share this question
Source: official GATE 2018 CS question paper and final answer key, organised by IIT Guwahati. Question paper · Answer key
More Compiler Design PYQs
- 2026 Session 1 · Q27Classify errors in three C string declarations
- 2026 Session 1 · Q28True statements about LL(1) parsing
- 2026 Session 1 · Q42Redundant (common) subexpressions in blocks B4 and B5 of a CFG
- 2026 Session 1 · Q53Compare two SDDs for type declarations
- 2026 Session 2 · Q35Count tokens produced by a lexer for a given string
- 2026 Session 2 · Q41Shift-reduce conflicts in the LR(0) table of a grammar