Consider the program below which uses six temporary variables a, b, c, d, e and f. Assuming that all the operations take their operands from registers, the minimum number of registers needed to execute this program without spilling is ____
- A. 5
- B. 6
- C. 3
- D. 4
✅ Correct Answer: 3
Explanation
Without spilling, original values should not be required later. Variable reuse is possible: d can be replaced by a e can be replaced by a f can be replaced by b Thus, the program can be executed using only 3 registers.
🎯 Happy Preparation — ACME Academy
