Intermediate Representations (IR): Three-Address Code, Syntax Trees, DAGs MCQs January 8, 2026December 14, 2024 by u930973931_answers 15 min Score: 0 Attempted: 0/15 Subscribe 1. What is the purpose of using Intermediate Representations (IR) in a compiler? (A) To generate machine code directly (B) To check for syntax errors (C) To provide debugging information (D) To simplify the compilation process and perform optimizations 2. Which of the following is a key feature of Three-Address Code (TAC)? (A) Each instruction contains at most three operands (B) It is a high-level language representation (C) It uses more than three operands in each instruction (D) It directly represents machine instructions 3. In Three-Address Code, how is a typical statement represented? (A) result = operand1 operator operand2 (B) result = operand1 operand2 (C) operand1 = operand2 operator operand3 (D) operand1 operator operand2 4. Which of the following is true about Syntax Trees? (A) They represent the abstract syntactic structure of a program (B) They are used only for debugging purposes (C) They directly map to machine code (D) They are used only during lexical analysis 5. What does a Directed Acyclic Graph (DAG) represent in compiler optimization? (A) The flow of control in a program (B) The dependencies between expressions, showing how values are computed (C) The sequence of machine instructions (D) The syntax structure of the program 6. What is the main difference between a Syntax Tree and a Directed Acyclic Graph (DAG)? (A) A syntax tree represents the full structure of a program, while a DAG represents only expression dependencies (B) Syntax trees allow for cycles, while DAGs do not (C) DAGs have more nodes than syntax trees (D) Syntax trees are used only in optimization, while DAGs are used in parsing 7. Why is Three-Address Code considered an important intermediate representation? (A) It closely resembles high-level source code (B) It is easier for humans to understand than machine code (C) It is only used for debugging (D) It allows for optimization and is platform-independent 8. What is the primary advantage of using DAGs in intermediate code representation? (A) They help in reducing the number of instructions by eliminating redundant expressions (B) They allow for cycle detection in the code (C) They are easy to translate into machine code (D) They help in debugging errors in the program 9. Which of the following is NOT a feature of Three-Address Code (TAC)? (A) It is used to simplify the task of machine code generation (B) It is machine-specific (C) Each TAC instruction can involve at most three operands (D) It is a low-level representation used in compilers 10. In a Syntax Tree, which of the following represents the root node? (A) The operator applied to two or more operands (B) The variable used in the program (C) The entire program (D) The constant values used in the program 11. Which intermediate representation would be most efficient for optimizing arithmetic expressions in a program? (A) Syntax tree (B) Three-address code (C) Directed Acyclic Graph (DAG) (D) Machine code 12. What does a “common subexpression” refer to in a DAG? (A) An expression that appears multiple times in the code (B) A node that has only one outgoing edge (C) A redundant operation that can be eliminated for optimization (D) A cycle in the graph 13. How does the use of Three-Address Code (TAC) affect the optimization phase of a compiler? (A) It simplifies the expression evaluation and helps identify common subexpressions (B) It eliminates the need for lexical analysis (C) It directly translates to the machine code without further optimization (D) It reduces the need for semantic analysis 14. Which of the following best describes a Directed Acyclic Graph (DAG) used in compilers? (A) A graph where nodes represent basic operations, and edges represent control flow (B) A graph used to store all possible execution paths of a program (C) A graph that only represents the structure of the source code (D) A graph that shows expression dependencies to remove redundant calculations 15. Which of the following is a benefit of using DAGs for expression evaluation in compilers? (A) They increase the time complexity of code generation (B) They can only be used for mathematical expressions (C) They reduce the readability of the code (D) They allow the compiler to perform code motion and eliminate redundant expressions