GATE Computer ScienceVery hardGATE CSE · UGC NET
In register allocation by graph colouring, variables v0…v6 have interference edges: the 5-cycle v0–v1–v2–v3–v4–v0, v5 interfering with each of v0…v4, and v6 interfering with v0 and v2. What is the minimum number of registers needed to avoid any spill?
- A. 3
- B. 5
- C. 4
- D. 6
Correct answer: C. 4
The largest clique has size 3, but the odd cycle v0…v4 needs 3 colours and v5 touches all of it, so 4 colours are required (v6 can reuse a colour).
More Compiler Design questions
- With Sethi–Ullman numbering (left leaf = 1, right leaf = 0, internal node = max(l,r) if l ≠ r else l+1), what is the label of the root of…
- Syntax-directed definition: E → E1 T { E.val = E1.val 2 + T.val }; E → T { E.val = T.val }; T → num { T.val = num.lexval }. For the input…
- Grammar: E → E + T | T; T → T F | F; F → id. An SLR(1) parser parses id + id id + id id (followed by ). Counting each shift and each…
- Grammar: S → A B C; A → a | ε; B → a | b | ε; C → a | c | ε. How many cells of the LL(1) table contain more than one production?
- A lexer uses longest match, with ties broken in favour of the rule listed first. Rules in order: IF = "if"; ELSE = "else"; ID =…
- Three-address code: 1: x = 0; 2: if a > b goto 8; 3: x = x + 1; 4: if x > 5 goto 7; 5: y = y 2; 6: goto 2; 7: y = y + 1; 8: if y < 100…