GATE CSE 2017 Session 1 Q62: Minimum registers for (a − 1) * (((b + c) / 3) + d) on a load/store machine
- Compiler Design
- 2 marks
- NAT
- No negative marking
Syllabus topic: Outside the current syllabus
Question
Consider the expression . Let X be the minimum number of registers required by an optimal code generation (without any register spill) algorithm for a load/store architecture, in which (i) only load and store instructions can have memory operands and (ii) arithmetic instructions can have only register or immediate operands. The value of X is ______.
Try it: numerical answer: type the value
Show answer and explanation
Answer: 2 (official GATE 2017 final answer key)
Concept used: Optimal code generation evaluates the subtree needing more registers first (Sethi–Ullman style) and reuses registers; on a load/store machine every variable must be loaded into a register before use.
First step: Evaluate the right subtree first, reusing registers where possible, and track how many registers are live at once, then evaluate while one result is held.
Full step-by-step solution
Loading…
Answer from the official final answer key. Found a mistake? Use Report issue and we will fix it.
Share this question
Source: official GATE 2017 Session 1 CS question paper and final answer key, organised by IIT Roorkee. 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