Search This Blog

Showing posts with label Theory of Automata. Show all posts
Showing posts with label Theory of Automata. Show all posts
Wednesday, 15 April 2026

Question Bank on Unit-5 of Automata & Compiler Design

0 comments

 

Analysis & Synthesis Process
of Compilation (Unit-5)


Multiple Choice Questions (MCQ)

1) Three-Address Code is called “Three Address” because:
        (i)    Each instruction can have atmost three operators 
        (ii)   Each instruction can have atmost three addresses (operands)
        (iii)  Each instruction can have exactly three operators
        (iv)  Each instruction can have exactly three addresses (operands)


2) The main advantage of generating Intermediate Code in a compiler is that:
        (i)    It allows better optimization independant of machine architecture
        (ii)   It eliminates the need for lexical analysis
        (iii)  It directly increases the run-time speed of the compiler
        (iv)  It reduces the number of syntax errors

3) Consider the expression a = b + c * d
A possible three-address code sequence is:
        (i)    t1 = b + c; a = t1 * d
        (ii)   t1 = c * d; a = b + t1
        (iii)  a = b + c * d
        (iv)  t1 = b * c; a = t1 + d

4) Which of the following techniques allows the compiler to fill in the address of forward jumps later (as the destinations of jump instructions are not known immediate) during intermedia code generation?
        (i)    Peephole Optimization
        (ii)   Backpatching
        (iii)  Register Allocation
        (iv)  Code Scheduling


5) Consider the following statements:
S1: A three-address code instruction contains at most three addresses

S2: The process of backpatching is used to know the forward jump addresses in control flow statements

Choose the correct optionn

        (i)   Only S1 is true         (ii)   Only S2 is true         (iii)  Both S1 and S2 are true         (iv)  Neither S1 nor S2 is true


6) Consider the following three-address code:

If a < b goto L1
t1 = a + b
L1: t2 = a * b

Which of the following is incorrect regarding the flow control in the code?         (i)    The expression will jump to L1 if a < b         (ii)   The addition t1 = a+b will execute when a >= b         (iii)  The multiplication t2 = a * b will execute only if a < b         (iv)  The multiplication t2 = a * b will always execute


7) Which of the following is NOT a task of the code generation phase of a compiler
        (i)    Instruction selection
        (ii)   Register allocation
        (iii)  Syntax analysis
        (iv)  Instruction ordering

8) In most modern compilers, the code generation phase takes which of the following as the input?
        (i)    The original source program
        (ii)   Intermediate code and information from the symbol table
        (iii)  Only the syntax tree
        (iv)  Target machine instruction

9) During a procedure call, which of the following actions are performed by the calling function (caller) before transferring the program control to the called function?           (i)    Evaluating actual arguments         (ii)   Passing parameters to the called function         (iii)  Saving necessary machine state such as return address         (iv)  All of the above

10) When the called function finishes execution, which component is used to determine where execution should resume in the calling function?         (i)    Control Link         (ii)   Access Link         (iii)  Return Address         (iv)  Local Variables


Descriptive Questions

Q1.    What is the runtime environment and what role does it play in program execution?

Q2.    Write three address code for the expression : 
            a+b*c – d /e

Q3.    Distinguish Syntax Directed Definition and Syntax Directed Translation?

Q4.    Discuss about various storage allocation strategies in runtime environment?

Q5.    Explain about different storage allocation strategies. 

Q6.    Compare and contrast the three main runtime storage organization techniques: static allocation, stack allocation, and heap allocation.

Q7.    Write the comparison among Static allocation, Stack allocation and Heap Allocation with their merits and limitations.

Q8.    Define Loop unrolling and Loop jamming? Also explain constant folding? 

Q9.    Define Three Address Codes. Outline various Three Address code representations for the expression:
            x + - y * (- y + z)

Q10.  Explain the procedure to translate Control Statements into Three address code with example.

Q11.  Explain the Code optimization techniques with example.

Q12.  Describe Register Allocation. Briefly explain the strategies available for register allocation and assignment.

Q13.  Explain the various issues in the design of code generation.

Q14.  Define object code generation and describe its importance in the compilation process. 





Continue reading →

Question Bank on Unit-4 of Automata & Compiler Design

0 comments

  

Introduction to Compilers &
Lexical Analysis (Unit-4)


Multiple Choice Questions (MCQ)

1) A Symbol Table in a Compiler is mainly used to:
        (i) Store Keywords
        (ii) Store Identifiers and their Attributes
        (iii) Generate Machine Code
        (iv) Perform Lexical Analysis

2) When can semantic errors be detected?
        (i) During Compile Time
        (ii) During Run Time
        (iii) Both (i) and (ii)
        (iv) None of the above

3) Which of the following mechanism is used to associate meaning (semantic information) with a Context Free Grammar (CFG)?
        (i) Syntax Directed Definition
        (ii) Parse Table
        (iii) Left Recursion
        (iv) Token Stream

4) Symbol Tables are mainly used during which phase of Compilation?
        (i) Syntax Analysis
        (ii) Semantic Analysis
        (iii) Code Generation
        (iv) Code Optimization

5) Which Data Structure is commonly used to implement a Symbol Table?
        (i) Queue (ii) Stack 
        (iii) Hash Table (iv) Tree

6) Which of the following are stored in a Symbol Table?
        (i) Variable Name (ii) Data Type
        (iii) Memory Location (iv) All the above

7) Average expected lookup time for a given key in a hash-table based Symbol Table is:
        (i) O(log n)
        (ii) O(n)
        (iii) O(1)
        (iv) None of the above


Descriptive Questions

Q1.  Explain different steps involved in a typical language processing system with a neat diagram.

Q2.  Identify the difference between compiler & assembler. Retrieve the phases of a typical compiler?

Q3.  Tabulating the difference between lexemes, patterns  and tokens. How do you recognize tokens in Lexical Analysis?

Q4.  Define token? Explain how Finite automata is used to recognize tokens in a program?

Q5.  List out the phases of compiler? What is the role of lexical analysis in constructing a compiler? 

Q6.  Explain the concept of a “pass” in compiler design. How do multiple passes contribute to the overall translation process?

Q7.  Discuss the contents and structure of a symbol table. What types of information are stored for each identifier?

Q8.  What is a symbol table. What role does the parser play in the overall compilation process? 

Q9.  Consider the following Conditional statement:
                if (x > 3) then y = 5 else y = 10;

        Explain how does a lexical analyzer help the above statement in the process of compilation?

Q10.  Recognize the LEX tools available for compiler constrction with an example.

Q11.  Write the structure and syntax of LEX-Lexical Analyzer Generators.

Q12.  Compare and contrast compiler writing from scratch with using a scanner generator like LEX (Lexical Analyzer Generator).

Q13.   Explain the translation process at each phase of compiler for the given expression d:=b+c*60

Q14.   What is LEX? Explain the importance of LEX tool with an example?

Q15.  Briefly describe the two main classifications of parser: top-down and bottom-up parsing. 

Q16.  Draw the syntax tree for the following expression: 
                (a+(b*c)^d-e)/(f+g) 

Q17.  Construct Syntax tree to evaluate the expression 2+3*4, through SDD.

Q18.  Construct LALR parser for the following grammar: 
                S-->CC         C-->aC         C-->d

Q19.  Construct a LALR parsing table for the grammar:
                S-->Aa | bAc | dc | bda A-->a 

Continue reading →

Question Bank on Unit-3 of Automata Theory

0 comments

 

Push Down Automata &
Turing Machine (Unit-3)


Descriptive Questions

Q1.  What are undecidable problems? Explain with example.

Q2.  Define Recursively Enumerable Language. 

Q3.  Define NP hard and NP completeness problem.

Q4.  Define CFG and what is the importance of it in compiler construction? 

Q5.  List the components of a Turing Machine. State Universal Turing Machine. 

Q6.  Construct Turing machine for the languages containing the set of all strings of balanced paranthesis?

Q7.  Explain the different types of Turing Machine.

Q8.   Give an overview of recursively enumerable language.

Q9.  Given a CFG, construct an equivalent PDA.

            Grammar: S → aSb | ε

        Detail the steps and transitions in the PDA.

Q10. Explain about Halting Problem of Turing machine.

Continue reading →
Thursday, 12 February 2026

Conversion of e-NFA to DFA

0 comments

Problems Solved during Class Room Teaching

Problem 1:



Problem 2:



Continue reading →
Saturday, 31 January 2026

Tutorials on Automata Theory & Compiler Design

0 comments

Tutorial Questions on ATCD



TUTORIAL-1

Q1.  For the given NFA which of the following is the equivalent DFA:

Q2.  Consider the following NFA and answer the following:
        a) Compute the ε-closure of each state.
        b) Convert the automaton to a DFA.

Q3.  Consider the following ε-NFA and do the following:
      a) Compute the ε-closure of each state.
      b) Convert the automaton to a DFA.

Q4.  Constructure the Finite Automata from the following 5-tuple notation:


Q5.  Convert the given ε-NFA to its equivalent DFA:



TUTORIAL-2

Q1.  Illustrate the construction of Non Deterministic Finite Automata for the Regular Expression: (a+b)*a

Q2.  Construct the regular expression for the language over the set S={0,1} that can have a set of all strings containing no three consecutive 0’s

Q3.  Construct a CFG to generate the binary strings that are Palindromes ex: 010, 00100, 101, 11011

Q4.  Identify the language generated by the following CFG:  S-->Aab; A-->Aab|b

Q5.  Construct the NFA for the regular expression r = ((01+10)*00)*

Q6. Constructure the Finite Automata using 5-tuple notation for the regular expression 1*01(0+11)*


TUTORIAL-3

Q1.  Give the formal definition of PDA.

Q2.  

Q3.

Q4.

Q5. Explain different types of Turing Machine.



TUTORIAL-4

Q1.  Explain different steps involved in a typical language processing system with a neat diagram.

Q2. Identify the difference between compiler & assembler.  Retrieve the phases of a typical compiler?

Q3. Explain the concept of a “pass” in compiler design. How do multiple passes contribute to the overall translation process?

Q4. List out the phases of compiler?  What is the role of lexical analysis in constructing a compiler?

Q5. Tabulating the difference between lexemes, patterns and tokens.  How do you recognize tokens in Lexical Analysis?

Q6. Discuss the contents and structure of a symbol table. What types of information are stored for each identifier?

Q7. Explain the translation process at each phase of compiler for the given expression d:=b+c*60


TUTORIAL-5

Q1.  Write three-address code for the expression:
            a+b*c-d/e

Q2. Compare and contrast the three main runtime storage organization techniques:
            i)    Static Allocation
            ii)    Stack Allocation
            iii)   Heap Allocation

Q3. Explain the procedure to translate Control Statements into Three Address Code with example.

Q4. Distinguish between Syntax Directed Definition and Syntax Directed Translation.

Q5. Define Three Address Codes. Outline the three address code representation for the following expression:
            x + -y * (-y + z)

Q6. Define Loop unrolling and Loop jamming. Also explain constant folding.

Continue reading →