HamroCSIT Logo
HAMRO CSIT
  • Course New
  • Entrance
    • Entrance Preparation
    • MCQ Questions
    • Colleges
    • Entrance Class
    • Entrance Books
    • Free Entrance Video Course
  • Semester
    • First Semester
    • Second Semester
    • Third Semester
    • Fourth Semester
    • Fifth Semester
    • Sixth Semester
    • Seventh Semester
    • Eight Semester
  • Questions
  • Subscription Automated
  • Notices
  • Articles
  • More
    • Ask Question
    • College Ambassadors
    • Financial Support Program
    • Contribute
    • Contact Us
Login Register
Hamro CSIT User Account
  • Sign In
  • Create Account


Shape | Hamro CSIT Shape | Hamro CSIT Shape | Hamro CSIT Shape | Hamro CSIT
Subject

Compiler Design and Construction

This course is designed to develop acquaintance with fundamental concepts of compiler design. The course starts with the basic concepts and also includes different phases of compilers like lexical analysis, syntax analysis, syntax-directed translation, type checking etc. in detail.

Subject Image | Hamro CSIT
  • Chapters
  • Syllabus
  • Question Banks
  • Questions
  • Text Book
  • Practical
  • Viva

Exam Year

  • CDC Model Set II
  • CDC Model Set I
  • CDC Question Bank 2081(new)
  • CDC Question Bank 2081
  • CDC Question Bank 2075
  • CDC Question Bank 2080
  • CDC Question Bank 2076
  • CDC Question Bank 2078

Tribhuvan University

Institute of Science and Technology

Model-Set-I

Bachelor Level / sixth-semester / Science

Computer Science and Information Technology( CSC365 )

Compiler Design and Construction

Full Marks: 60 + 20 + 20

Pass Marks: 24 + 8 + 8

Time: 3 Hours

Candidates are required to give their answers in their own words as far as practicable.

The figures in the margin indicate full marks.

Section A

Attempt any TWO questions.

1

What is ambiguous grammar? Explain the “Dangling Else” problem with example. Show how to resolve it.

Construct the LL(1) parsing table for the following grammar (after removing left recursion if needed):

E → E + T | T

T → T * F | F  

F → (E) | id

Parse the string id + id * id using this table.

2

What is backpatching? Why is it used in code generation? Generate three-address code with backpatching for the following code:

while (a < b) {

    if (c < d) 

        x = y + z;

    else

        x = y – z;

}

Also show the quadruples and explain how backpatch function works.

3

Convert the following regular expression to NFA using Thompson’s construction:

(a|b)*a(a|b)

Then convert this NFA to DFA using subset construction method. Finally, minimize the DFA using state minimization algorithm.

Section B

Attempt any EIGHT questions.

4

What is recursive descent parsing? Write a recursive descent parser for the following grammar:

S → aS | bA

A → bA | c

Show how it parses the string “aabc”.

5

Given the following DFA with states {A, B, C, D, E, F}, minimize it using state minimization algorithm:

Start state: A

Final states: {D, F}

Transitions:

δ(A, 0) = B,  δ(A, 1) = C

δ(B, 0) = D,  δ(B, 1) = E

δ(C, 0) = E,  δ(C, 1) = D

δ(D, 0) = D,  δ(D, 1) = D

δ(E, 0) = F,  δ(E, 1) = F

δ(F, 0) = F,  δ(F, 1) = F

Show all steps clearly including partition refinement.

6

Compute FIRST and FOLLOW for all non-terminals in the grammar:

S → ACB | CbB | Ba

A → da | BC

B → g | ε

C → h | ε

Construct the LL(1) parsing table. Is this grammar LL(1)? Justify your answer.

7

What are handles in LR parsing? Explain handle pruning with example. For the grammar:

E → E + T | T

T → T * F | F

F → (E) | id

Show the handle at each step for reducing the string: id + id * id

8

What is intermediate code? Explain the advantages of three-address code. Generate three-address code, quadruples, triples, and indirect triples for:

a = b * (-c) + d / e

9

Write syntax-directed definitions for translating boolean expressions into three-address code using backpatching. Generate code for:

if (a < b && c > d || e == f) 

    x = 1;

else

    x = 0;

10

Explain the following code optimization techniques with examples:

  1. a) Copy propagation
    b) Constant folding
    c) Dead code elimination
    d) Strength reduction

Apply all applicable optimizations to:

x = 3;

y = x;

z = x + 5;

a = y * 2;

b = 8;

c = b / 2;

d = a + 0;

11

What is register allocation? Explain register allocation using graph coloring algorithm. Given the following live ranges, perform register allocation with 3 registers available:

Variables: a, b, c, d, e

 

Live ranges overlap:

– a and b overlap

– b and c overlap  

– c and d overlap

– d and e overlap

– a and c don’t overlap

– b and e overlap

 

Draw the interference graph and assign registers.

12

Write short notes on:

a) Error recovery in parsing (panic mode, phrase-level recovery)
b) Parameter passing mechanisms (call by value, call by reference, call by name)

Compiler Design and Construction Question Bank Solution Model-Set-I
Solution Video
Solution
Share

Share this link via

Or copy link

logoHAMROCSIT

Hamro CSIT is a comprehensive web and mobile platform that provides B.Sc. CSIT students with resources like notes, syllabi, question banks, solved past papers, practical files, and free entrance preparation materials — all in one place.

  • [email protected]
Semester
  • First Semester
  • Second Semester
  • Third Semester
  • Fourth Semester
  • Fifth Semester
  • Sixth Semester
  • Seventh Semester
  • Eighth Semester
Links
  • About Us
  • FAQs
  • Sitemap
  • Privacy Policy
  • Terms and Conditions
  • College Ambassadors
  • Financial Support Program
Hits Counter
20229890
Google Play App Store
Follow Us

Copyright 2026 | HAMROCSIT | All Right Reserved

Official Payment Partner Esewa Logo
HAMROCSIT.COM

Copyright 2024 | HAMROCSIT.COM | All Right Reserved - Nymna Technology