Compiler Construction MCQs with Answers

Practice important Compiler Construction MCQs with answers and explanations.

Multiple Choice Questions

Q1191: Division operator typically requires how many registers?
  • A: One
  • B: Two
  • C: Three
  • D: Four
View Answer
B

Q1192: The general register allocation problem is known to be:
  • A: P
  • B: NP
  • C: NP-complete
  • D: Undecidable
View Answer
C

Q1193: Graph coloring in register allocation ensures that:
  • A: adjacent nodes share colors
  • B: no two connected nodes share colors
  • C: nodes are deleted
  • D: nodes are merged
View Answer
B

Q1194: In register allocation, the interference graph has:
  • A: one node per instruction
  • B: one node per variable
  • C: one edge per instruction
  • D: no edges
View Answer
B

Q1195: An edge between two nodes in an interference graph indicates:
  • A: variables are independent
  • B: variables live at the same time
  • C: variables are equal
  • D: variables can be merged
View Answer
B

Q1196: In the register allocation algorithm, what happens when all nodes have degree >= K?
  • A: All nodes get colors
  • B: Spill nodes to memory
  • C: Stop allocation
  • D: Increase registers
View Answer
B

Q1197: What does the 'Simplify' step in graph coloring do?
  • A: Remove nodes with many neighbors
  • B: Remove nodes with fewer than K neighbors
  • C: Assign colors
  • D: Mark spill nodes
View Answer
B

Q1198: Assigning colors in graph coloring starts from:
  • A: the original graph
  • B: an empty graph
  • C: the largest node
  • D: the smallest node
View Answer
B

Q1199: Live variables are saved at the end of blocks because:
  • A: they may be needed later
  • B: they are not used again
  • C: to free up registers
  • D: to optimize CPU cycles
View Answer
A

Q1200: The algorithm to generate DAG from 3-address code involves checking for:
  • A: operator existence
  • B: variable existence
  • C: node existence
  • D: memory location
View Answer
C

Test Your Knowledge

Take a timed quiz on Compiler Construction

🚀 Start Quiz Now