Question 1
Consider the following compiler phases and compiler tasks.
Which one of the following correctly matches the compiler phases with their primary tasks?
P-4, Q-3, R-2, S-1
P-3, Q-4, R-2, S-1
P-4, Q-1, R-2, S-3
P-2, Q-3, R-4, S-1
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.
Consider the following compiler phases and compiler tasks.
Which one of the following correctly matches the compiler phases with their primary tasks?
P-4, Q-3, R-2, S-1
P-3, Q-4, R-2, S-1
P-4, Q-1, R-2, S-3
P-2, Q-3, R-4, S-1
Correct answer
P-4, Q-3, R-2, S-1
Which of the following describes a key programmatic difference between the functionality of an Interpreter and a Compiler toolchain?
Compilers execute code step-by-step at runtime, whereas interpreters translate the entire source program before execution.
Interpreters can provide immediate statement-level runtime feedback.
The machine-language target program produced by a compiler is typically 10 to 100 times slower than interpreter execution.
Compilers completely eliminate the need for a runtime environment or stack frame allocation.
Correct answer
Interpreters can provide immediate statement-level runtime feedback.
Lexical Analysis
Syntax Analysis
Code Generation
Semantic Analysis
Correct answer
Semantic Analysis
The compiler driver generates a syntax error because macro parameters require explicit parentheses.
Correct answer
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?
24
30
39
48
Correct answer
39
Which of the following is NOT a responsibility of the lexical analyzer?
Removing white spaces and comments
Recognizing keywords and identifiers
Checking whether parentheses are properly balanced
Producing tokens for the parser
Correct answer
Checking whether parentheses are properly balanced
All strings with at most one b
All strings where no two b's are adjacent
All strings ending in a
All strings with an equal number of a's and b's
Correct answer
All strings where no two b's are adjacent
Correct answer
Which of the following statements correctly describes machine-independent optimizations?
They can be performed before generating target machine code.
They depend on the instruction set of the target processor.
Constant Folding is an example of machine-independent optimization.
Copy Propagation is an example of machine-independent optimization.
Correct answers
They can be performed before generating target machine code.
Constant Folding is an example of machine-independent optimization.
Copy Propagation is an example of machine-independent optimization.
Consider the following declarations:
The compiler generates Three-Address Code (TAC) for the statement
Correct answer: 3
Correct answer
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?
Symbol Table = 5, Constant Table = 3
Symbol Table = 4, Constant Table = 2
Symbol Table = 5, Constant Table = 2
Symbol Table = 6, Constant Table = 2
Correct answer
Symbol Table = 5, Constant Table = 2
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?
Correct answer
A compiler back-end generates the following Three-Address Code (TAC) for an image enhancement algorithm.
Correct answer: 3
Which of the following strings are accepted by the DFA?
10111
1010
0100
100001
0001
Correct answers
1010
100001
Consider the following statements about Deterministic Finite Automata (DFA) and Nondeterministic Finite Automata (NFA).
Which of the following statement(s) is/are correct?
There exist languages that can be accepted by an NFA but not by any DFA.
An NFA accepts an input string if at least one computation path reaches an accepting state after reading the entire input.
A DFA has exactly one transition for every input symbol from each state.
An NFA accepts an input string only if all possible computation paths end in accepting states.
Every language accepted by an NFA can also be accepted by a DFA.
Correct answers
An NFA accepts an input string if at least one computation path reaches an accepting state after reading the entire input.
A DFA has exactly one transition for every input symbol from each state.
Every language accepted by an NFA can also be accepted by a DFA.