Code: 105601Computer Science & Eng.6th Semester7 Examination Papers

Compiler Design

Official Bihar Engineering University examination question papers, marks distribution, and questions transcript. Available exam sessions: 2026, 2025, 2023, 2022, 2019, 2018, 2017.

Exam Year:

Get Instant AI Answers on this Paper

Open BEU Connect Android app to solve any numerical or derive formulas step by step.

Ask AI in App
Official Exam Paper TranscriptB.Tech 6th Semester Examination, 2026
Bihar Engineering University, Patna
B.Tech 6th Semester Exam., 2026

Compiler Design

Time: 03 HoursCode: 105601Semester: VIFull Marks: 70

Instructions:

  1. The marks are indicated in the right-hand margin.
  2. There are NINE questions in this paper.
  3. Attempt FIVE questions in all.
  4. Question No. 1 is compulsory.
Q.1 Choose the correct option / answer the following (Any seven question only):[2 x 7 = 14]
  1. Consider the statement: int total = 25; Which of the following represents a lexeme?

    1. int
    2. 25
    3. total
    4. All of the Above
  2. The regular expression (a|b)* represents:

    1. Strings containing only a
    2. Strings containing only b
    3. All strings over {a,b}, including ε
    4. Strings beginning with ab
  3. Which of the following is a problem for a top-down parser?

    1. Left recursion
    2. Right recursion
    3. Ambiguity only
    4. Bottom-up derivation
  4. In bottom-up parsing, the parser constructs:

    1. Leftmost derivation
    2. Rightmost derivation
    3. Reverse of a rightmost derivation
    4. Leftmost derivation in reverse
  5. Consider a symbol table implemented using hashing with table size 10. For key 27, using h(k) = k mod 10, the initial position is:

    1. 5
    2. 7
    3. 6
    4. 8
  6. Under static scoping, the meaning of a variable reference is determined primarily by:

    1. Runtime call sequence
    2. CPU register contents
    3. Heap location
    4. Lexical program structure
  7. Which optimization eliminates repeated computation of the same expression?

    1. Loop interchange
    2. Dead-code elimination only
    3. Common subexpression elimination
    4. Register allocation
  8. Which pipeline hazard occurs when an instruction depends on the result of a previous instruction?

    1. Structural hazard
    2. Data hazard
    3. Syntax hazard
    4. Memory hazard
  9. Dynamic method dispatch is primarily used to implement:

    1. Lexical analysis
    2. Constant folding
    3. Runtime polymorphism
    4. Register allocation
  10. Which statement is true regarding DFA and NFA?

    1. NFA is strictly more powerful than DFA
    2. DFA and NFA recognize the same class of languages
    3. DFA is strictly more powerful than NFA
    4. Every NFA requires more states than every equivalent DFA
Q.2 Solve both questions :[7 x 2 = 14]
  1. Explain the different phases of compilation with a suitable example. Show the input and output produced at each phase.

  2. Construct a DFA over {0,1} that accepts all strings containing an even number of 0s and an odd number of 1s. Verify the constructed DFA using suitable accepted and rejected input strings.

Q.3 Solve both questions :[7 x 2 = 14]
  1. For a lexical analyzer, design regular expressions to recognize the following token classes:
    (i) Identifiers beginning with a letter and containing letters and digits thereafter.
    (ii) Unsigned integer constants.
    (iii) Relational operators <, <=, >, >=, ==, and !=.

  2. Consider the grammar:
    S→ABC
    A→aA | ε
    B→bB | ε
    C→cC | d
    Compute the FIRST and FOLLOW sets for all non-terminals. Using these, construct the LL(1) parsing table. Use the parsing table to show the parsing steps for the input string “aabd”.

Q.4 Solve both questions :[7 x 2 = 14]
  1. Explain ambiguity in context-free grammars. Illustrate how ambiguity can lead to shift-reduce or reduce-reduce conflicts during LR parsing.

  2. Construct a transition diagram for the Pushdown Automaton for the language:
    L = {wcwR | w ∈ {a,b}*}

Q.5 Solve both questions :[7 x 2 = 14]
  1. Explain the structure of an activation record and its role during procedure execution.

  2. Discuss the structure of a symbol table and the information stored for each identifier.

Q.6 Solve both questions :[7 x 2 = 14]
  1. Generate the three-address code for the following expression. Then represent the generated code using quadruple, triple, and indirect-triple representations.
    x=a*(b+c)−d/e

  2. Explain the construction of basic blocks and control-flow graphs (CFGs) in compiler design using a suitable three-address code example.

Q.7 Solve both questions :[7 x 2 = 14]
  1. Explain cache locality and its importance in loop optimization.

  2. Explain the major stages involved in target code generation in a compiler. Discuss instruction selection, register allocation, and instruction scheduling, and explain how each stage contributes to generating efficient target machine code.

Q.8 Solve both questions :[7 x 2 = 14]
  1. Discuss the major challenges involved in compiling object-oriented features such as classes, inheritance, and polymorphism.

  2. Consider the following grammar:
    E → E + T | T
    T → T * F | F
    F → digit
    Define suitable synthesized attributes to evaluate an arithmetic expression. Construct the annotated syntax tree and evaluate the following expression:
    3 + 5 * 2

Q.9 Write a short note on any two of the following:[7 x 2 = 14]
  1. SLR(1) parser

  2. Syntax Directed Definition

  3. peep-hole optimization

  4. Attribute grammar

Related Official Syllabus

Compiler Design

105601

Official BEU curriculum units & topics for this examination subject.

Unit 1.0: Introduction

Phases of compilation and overview • Lexical Analysis (scanner): Regular languages, finite automata, regular expressions • From regular expressions to finite automata • Scanner generator (lex, flex)

Unit 2.0: Syntax Analysis (Parser)

Context-free languages and grammars • Push-down automata • LL(1) grammars and top-down parsing • Operator grammars • LR(0), SLR(1), LR(1), LALR(1) grammars and bottom-up parsing • Ambiguity and LR parsing • LALR(1) parser generator (yacc, bison)

Unit 3.0: Semantic Analysis

Attribute grammars • Syntax directed definition • Evaluation and flow of attribute in a syntax tree • Symbol Table: Its structure, symbol attributes and management • Run-time environment: Procedure activation, parameter passing, value return, memory allocation, and scope

Unit 4.0: Intermediate Code Generation

Translation of different language features • Different types of intermediate forms • Code Improvement (optimization) Analysis: control-flow, data-flow dependence etc. • Code improvement: local optimization, global optimization, loop optimization and peep-hole optimization

Unit 5.0: Architecture Dependent Code Improvement

Instruction scheduling (for pipeline) • Loop optimization (for cache memory) • Register allocation and target code generation

View Complete 6th Semester Syllabus

Prepare Better with BEU Connect

  • Download papers for 100% offline study
  • Ask AI for step-by-step problem breakdown
  • Attempt official GATE CBT mock tests
  • Calculate SGPA and track attendance
Download Android App