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?

  1. A. 3
  2. B. 5
  3. C. 4
  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

Exams that ask this topic