Compiler Construction MCQs with Answers
Practice important Compiler Construction MCQs with answers and explanations.
Multiple Choice Questions
Q1181: When generating a DAG from 3-address code, if a node for "y op z" exists, we should:
- A: add y
- B: add z
- C: add x to the node label
- D: remove node
View Answer
C
Q1182: In DAG generation, if y or z exist in the DAG, we:
- A: create new leaves
- B: point to existing nodes
- C: delete old nodes
- D: create new operators
View Answer
B
Q1183: If a variable x existed previously as a leaf in the DAG, we should:
- A: remove it
- B: subscript that entry
- C: rename it
- D: delete it
View Answer
B
Q1184: DAGs can have nodes with multiple labels because they represent:
- A: instructions
- B: operators
- C: computed values
- D: registers
View Answer
C
Q1185: Which of the following 3-address code lines correspond to a DAG node labeled '+'?
- A: t1 = a * a
- B: a = b + c
- C: c = t1 * b
- D: t2 = c + b
View Answer
B
Q1186: In DAG-based optimization, a node with more than one parent indicates a:
- A: unique expression
- B: common sub-expression
- C: dead code
- D: loop
View Answer
B
Q1187: Which traversal order of the given DAG resulted in fewer machine instructions?
- A: Order 1
- B: Order 2
- C: Both same
- D: None
View Answer
B
Q1188: Reordering DAG traversal can improve code by:
- A: reducing memory
- B: increasing registers
- C: reducing machine instructions
- D: increasing registers usage
View Answer
C
Q1189: Registers in a machine are considered a ________ resource.
- A: unlimited
- B: scarce
- C: infinite
- D: optional
View Answer
B
Q1190: The program counter is kept in a _________.
- A: cache
- B: memory
- C: register
- D: stack
View Answer
C