Key takeaways
- FIRST and FOLLOW, LL(1) tables and LR parsing tables are the highest-scoring numericals.
- Draw the phases of a compiler with the output of each phase for a sample statement.
- Three-address code and DAG construction are short, reliable long-answer topics.
- These are practice questions, not past papers; check your own syllabus and official previous papers.
About these important questions
This page lists the most important Compiler Design questions for B.Tech CSE and IT exams, arranged unit by unit. The units follow the standard syllabus that most Indian technical universities share, so the order may differ slightly from yours.
Please note: these are practice questions based on common syllabus topics. They are not verified past papers, and we do not claim that any question will appear in your exam. Check your own university syllabus first, then solve the official previous year papers. AKTU students can download them from the AKTU old question paper archive.
Unit 1: Introduction and Lexical Analysis
Covers compiler phases, passes, bootstrapping and lexical analysis.
Short questions (2 marks)
- Differentiate between a compiler and an interpreter.
- Define a token, a pattern and a lexeme.
- What is bootstrapping?
Long questions
- Explain the phases of a compiler with a diagram, and show the output of each phase for
position = initial + rate * 60. - Explain the role of the lexical analyser and input buffering with sentinels.
- Explain the structure of a LEX program with an example.
- Construct a DFA directly from a regular expression such as (a | b)*abb.
- Compare single-pass and multi-pass compilers, and explain cross compilers.
Unit 2: Syntax Analysis: Top-Down and Operator Precedence
Covers CFGs for parsing, top-down parsing and operator precedence parsing.
Short questions (2 marks)
- What is left recursion? Why must it be removed for top-down parsing?
- What is left factoring?
- When is a grammar LL(1)?
Long questions
- Remove left recursion from E → E + T | T, T → T * F | F, F → (E) | id.
- Find FIRST and FOLLOW for the resulting grammar and build the LL(1) parsing table.
- Parse the input
id + id * idusing the LL(1) table, showing the stack, input and action. - Explain recursive descent parsing with an example.
- Build an operator precedence table and parse a string.
Unit 3: Bottom-Up Parsing and Syntax-Directed Translation
Covers shift-reduce parsing, LR parsers and syntax-directed definitions.
Short questions (2 marks)
- What is a handle?
- Name the conflicts that can occur in shift-reduce parsing.
- Differentiate between synthesised and inherited attributes.
Long questions
- Construct the canonical LR(0) items and the SLR parsing table for a given grammar.
- Construct the CLR (LR(1)) and LALR parsing tables for a grammar such as S → CC, C → cC | d.
- Compare SLR, CLR and LALR parsers.
- Write a syntax-directed definition for a desk calculator and draw an annotated parse tree.
- Explain S-attributed and L-attributed definitions.
- Explain YACC and how it works with LEX.
Unit 4: Intermediate Code, Symbol Table and Runtime Environment
Covers intermediate representations, symbol tables and storage organisation.
Short questions (2 marks)
- What is three-address code?
- Differentiate between quadruples and triples.
- What is an activation record?
Long questions
- Write three-address code for an expression such as a = b * -c + b * -c and represent it as quadruples, triples and indirect triples.
- Generate three-address code for an if-else statement and a while loop using backpatching.
- Explain symbol table organisation using lists, trees and hash tables.
- Explain the contents of an activation record with a diagram.
- Explain static, stack and heap storage allocation.
- Explain parameter passing methods: call by value, reference and name.
Unit 5: Code Optimisation and Code Generation
Covers basic blocks, flow graphs, DAGs, optimisations and code generation.
Short questions (2 marks)
- What is a basic block?
- Define dead code elimination.
- What is peephole optimisation?
Long questions
- Partition three-address code into basic blocks and draw the flow graph.
- Construct a DAG for a basic block and explain its uses.
- Explain local and loop optimisations: common subexpression elimination, constant folding, code motion, strength reduction and induction variable elimination.
- Explain data flow analysis: reaching definitions and live variable analysis.
- Explain the issues in the design of a code generator.
- Explain peephole optimisation with examples.
Sample answer outline: FIRST and FOLLOW sets
For the grammar E → TE', E' → +TE' | ε, T → FT', T' → *FT' | ε, F → (E) | id, answer like this:
- State the rules. FIRST(X) is the set of terminals that can begin a string derived from X. FOLLOW(A) is the set of terminals that can appear right after A in some sentential form, and $ is in FOLLOW of the start symbol.
- Compute FIRST bottom-up. FIRST(F) = { (, id }. FIRST(T) = FIRST(F). FIRST(E) = FIRST(T). FIRST(E') = { +, ε }. FIRST(T') = { *, ε }.
- Compute FOLLOW. FOLLOW(E) = { ), $ }. FOLLOW(E') = FOLLOW(E). FOLLOW(T) = { +, ), $ }. FOLLOW(T') = FOLLOW(T). FOLLOW(F) = { *, +, ), $ }.
- Show it in a table. One row per non-terminal with FIRST and FOLLOW columns.
- Use it. Each production A → α goes in table cell [A, a] for every a in FIRST(α). If ε is in FIRST(α), also add it for every b in FOLLOW(A). If no cell has two entries, the grammar is LL(1).
Marks weightage and how to write answers
A common pattern, used by AKTU and many other universities, has a compulsory short-answer section that covers every unit, followed by long-answer questions with a choice inside each unit. Marks per question change between universities and years, so confirm the scheme on a recent official paper.
- Short answers (about 2 marks): a crisp definition, one example or diagram, and nothing more. Three to five lines is enough.
- Long answers (7 to 10 marks): start with a definition, add a labelled diagram or table, explain the steps, and finish with an example, advantages or a comparison.
- For parsing tables, draw them with ruled rows and columns. A table that is hard to read loses marks even when correct.
- Always show a parse of a sample string after building a table. It proves the table works.
A 7-day revision plan for Compiler Design
- Days 1 to 5: one unit a day. Read your notes, then write the long answers for that unit from memory and check them against your notes.
- Day 6: redo left recursion removal, FIRST and FOLLOW, one LL(1) table, one SLR and one LALR table, and a DAG.
- Day 7: solve one full official previous year paper in three hours, then check which units cost you time.
Keep a single sheet of formulas, definitions and diagrams for the last hour before the exam.
Download Compiler Design Important Questions PDF
Compiler Design Important Questions PDF
The PDF carries the same content as this page in a clean, print-ready layout, so you can read it offline and keep it for revision.
5 pages · 116 KB · PDF · Updated 5 Nov 2026