uiz Space

May 2026 term · Compiler Design · BSCS4032

Compiler Design Quiz 1: 19 July 2026 (May 2026 term)

The IIT Madras BS Compiler Design (Compiler Design) Quiz 1 paper sat on 19 Jul 2026, in the May 2026 term: 16 questions for 41 marks in 120 minutes. Every question is below with its answer. Take it as a timed mock test to be marked, or read it through first.

Questions
16
Marks
41
Duration
120 min
MCQ
11
MSQ
3
Numerical
2

Updated

Official paper: Compiler Design 16 Jul 26 · No negative marking.

Question 1

+2 marksOne correct option

Consider the following compiler phases and compiler tasks.

Which one of the following correctly matches the compiler phases with their primary tasks?

  1. A

    P-4, Q-3, R-2, S-1

  2. B

    P-3, Q-4, R-2, S-1

  3. C

    P-4, Q-1, R-2, S-3

  4. D

    P-2, Q-3, R-4, S-1

Show answer

Correct answer

  • A

    P-4, Q-3, R-2, S-1

Question 2

+2 marksOne correct option

Which of the following describes a key programmatic difference between the functionality of an Interpreter and a Compiler toolchain?

  1. A

    Compilers execute code step-by-step at runtime, whereas interpreters translate the entire source program before execution.

  2. B

    Interpreters can provide immediate statement-level runtime feedback.

  3. C

    The machine-language target program produced by a compiler is typically 10 to 100 times slower than interpreter execution.

  4. D

    Compilers completely eliminate the need for a runtime environment or stack frame allocation.

Show answer

Correct answer

  • B

    Interpreters can provide immediate statement-level runtime feedback.

Question 3

+2 marksOne correct option
  1. A

    Lexical Analysis

  2. B

    Syntax Analysis

  3. C

    Code Generation

  4. D

    Semantic Analysis

Show answer

Correct answer

  • D

    Semantic Analysis

Question 4

+2 marksOne correct option
  1. A
  2. B
  3. C
  4. D

    The compiler driver generates a syntax error because macro parameters require explicit parentheses.

Show answer

Correct answer

  • B

Question 5

+2 marksOne correct option

A compiler architecture uses a common Intermediate Representation (IR). Initially, it supports 6 source languages and 4 target architectures.
Later, support for 3 new source languages and 2 new target architectures is added.
Without using IR, the compiler requires one translator for every source-target pair.
With IR, how many fewer translators/components are required after the expansion?

  1. A

    24

  2. B

    30

  3. C

    39

  4. D

    48

Show answer

Correct answer

  • C

    39

Question 6

+2 marksOne correct option

Which of the following is NOT a responsibility of the lexical analyzer?

  1. A

    Removing white spaces and comments

  2. B

    Recognizing keywords and identifiers

  3. C

    Checking whether parentheses are properly balanced

  4. D

    Producing tokens for the parser

Show answer

Correct answer

  • C

    Checking whether parentheses are properly balanced

Question 7

+2 marksOne correct option
  1. A

    All strings with at most one b

  2. B

    All strings where no two b's are adjacent

  3. C

    All strings ending in a

  4. D

    All strings with an equal number of a's and b's

Show answer

Correct answer

  • B

    All strings where no two b's are adjacent

Question 8

+2 marksOne correct option
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 9

+2 marksOne or more correct options

Which of the following statements correctly describes machine-independent optimizations?

Select all that apply.

  1. A

    They can be performed before generating target machine code.

  2. B

    They depend on the instruction set of the target processor.

  3. C

    Constant Folding is an example of machine-independent optimization.

  4. D

    Copy Propagation is an example of machine-independent optimization.

Show answer

Correct answers

  • A

    They can be performed before generating target machine code.

  • C

    Constant Folding is an example of machine-independent optimization.

  • D

    Copy Propagation is an example of machine-independent optimization.

Question 10

+3 marksNumerical answer

Consider the following declarations:

The compiler generates Three-Address Code (TAC) for the statement

Show answer

Correct answer: 3

Question 11

+4 marksOne correct option
  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • A

Question 12

+3 marksOne correct option

A compiler performs lexical analysis and stores: every unique identifier in the Symbol Table,• every unique integer constant in the Constant Table.• Keywords, operators, delimiters, and punctuation symbols are not stored in either table.
Consider the following program.

How many entries will be present in the Symbol Table and the Constant Table, respectively?

  1. A

    Symbol Table = 5, Constant Table = 3

  2. B

    Symbol Table = 4, Constant Table = 2

  3. C

    Symbol Table = 5, Constant Table = 2

  4. D

    Symbol Table = 6, Constant Table = 2

Show answer

Correct answer

  • C

    Symbol Table = 5, Constant Table = 2

Question 13

+3 marksOne correct option

Assume that any undefined transition leads to a dead (trap) state, which is not shown in the table.
Which of the following regular expressions describes the language accepted by the DFA?

  1. A
  2. B
  3. C
  4. D
Show answer

Correct answer

  • B

Question 14

+4 marksNumerical answer

A compiler back-end generates the following Three-Address Code (TAC) for an image enhancement algorithm.

Show answer

Correct answer: 3

Question 15

+3 marksOne or more correct options

Which of the following strings are accepted by the DFA?

Select all that apply.

  1. A

    10111

  2. B

    1010

  3. C

    0100

  4. D

    100001

  5. E

    0001

Show answer

Correct answers

  • B

    1010

  • D

    100001

Question 16

+3 marksOne or more correct options

Consider the following statements about Deterministic Finite Automata (DFA) and Nondeterministic Finite Automata (NFA).
Which of the following statement(s) is/are correct?

Select all that apply.

  1. A

    There exist languages that can be accepted by an NFA but not by any DFA.

  2. B

    An NFA accepts an input string if at least one computation path reaches an accepting state after reading the entire input.

  3. C

    A DFA has exactly one transition for every input symbol from each state.

  4. D

    An NFA accepts an input string only if all possible computation paths end in accepting states.

  5. E

    Every language accepted by an NFA can also be accepted by a DFA.

Show answer

Correct answers

  • B

    An NFA accepts an input string if at least one computation path reaches an accepting state after reading the entire input.

  • C

    A DFA has exactly one transition for every input symbol from each state.

  • E

    Every language accepted by an NFA can also be accepted by a DFA.