All Question paper with solution mean Bachelorexam.com

Compiler Design KCS-502/KIT-052 Aktu Btech Short Question, Notes Pdf

Discover Short Question Notes on Compiler Design for B.Tech from the AKTU Quantum Book. Examine the fundamentals of creating effective compilers, optimising them, and translating them into machine code.

Dudes 🤔.. You want more useful details regarding this subject. Please keep in mind this as well.

Important Questions For Compiler Design:
*Quantum *B.tech-Syllabus
*Circulars *B.tech AKTU RESULT
* Btech 3rd Year * Aktu Solved Question Paper

Unit-I: Introduction to Compiler (Short Question)

Q1. State any two reasons as a why phases of compiler should be grouped.

Ans. Two reasons for phases of compiler to be grouped are:

  • 1. It helps in the creation of compilers for various source languages.
  • 2. Several compilers share similar front end phases.

Q2. Discuss the challenges in compiler design.

Ans. Challenges in compiler design are :

  • i. There must be no errors in the compiler.
  • ii. It must provide accurate machine code that executes quickly.
  • iii. The speed of the compiler itself, i.e., the ratio of the compilation time to the programme size, must be favourable.
  • iv. It has to be transportable (i.e., modular, supporting separate compilation).
  • v. It ought to display error and diagnostic messages.

Q3. What is translator ?  

Ans. A translator transforms a programme written in a source language into a programme written in a target language.


Q4. Differentiate between compiler and assembler. 

Ans. 

S. No.CompilerAssembler 
1.High level language is transformed into machine language.It transforms machine language from assembly language.  
2.Debugging is slow.Debugging is fast.  
3.It is used by C, C++.It is used by assembly language. 

Q5. What do you mean by regular expression ?

Ans. Mathematical symbolisms known as regular expressions are used to characterize a set of strings in a particular language. It offers simple and practical notation for expressing tokens. 


Q6. Differentiate between compilers and interpreters. 

Ans. 

S. No.CompilerInterpreter
1.It scans through the entire source code and lists each syntax error as it is found.It scans each line individually, and if there are any syntax errors, the programme immediately stops running.
2.The compiler’s output is saved in a file. Hence, the file need not be continuously compiled.The machine code that an interpreter generates is not stored in any file. As a result, each time, we must interpret the file.
3.It takes less time to execute. It takes more time to execute.

Q7. What is cross compiler ? 

Ans. A cross compiler is a compiler that has the ability to generate executable code for platforms other than the one it is currently executing on.  


Q8. How YACC can be used to generate parser ?

Ans. 1. YACC is a tool which will produce a parser for a given grammar. 

2. A (LALRO) grammar compilation software called YACC is used to generate source code. As a result, a parser is created using it.


Q9. Write regular expression to describe a language consist of strings made of even number a and b. 

Ans. Language of DFA which accept even number of a and b is given by: 

Write regular expression to describe a language consist of strings made of even number a and b. Compiler Design

Regular expression for above DFA:

(aa + bb + (ab + aa aa + bb)* (ab + ba))*


Q10. Write a CF grammar to represent palindrome. 

Ans. 

Write a CF grammar to represent palindrome.

Q11. List the features of good compiler. 

Ans. Features of good compiler are:  

  • i. It takes less time to compile the vast amount of code.
  • ii. The source language can be translated into another language with decreased memory usage.
  • iii. If the source programme needs to be amended frequently, it can only compile the modified code segment.
  • iv. Effective compilers work closely with the operating system while addressing hardware interrupts.

Q12. What are the two parts of a compilation ? Explain briefly. 

Ans. Two parts of a compilation are:

  • 1.  Analysis part: It separates the source programme into its component parts and produces a middle representation of the source programme.  
  • 2. Synthesis part: It constructs the desire target program from the intermediate representation.

Q13. What are the classifications of a compiler ?

Ans. Classification of a compiler:

  • 1. Single pass compiler 
  • 2. Two pass compiler 
  • 3. Multiple pass compiler

Unit-II: Basic Parsing Techniques (Short Question)

Q1. State the problems associated with the top-down parsing.

Ans. Problems associated with top-down parsing are: 

  • 1. Backtracking 
  • 2. Left recursion 
  • 3. Left factoring 
  • 4. Ambiguity

Q2. What is the role of left recursion ?

Ans. A string is recognised as being a component of a language by the fact that it breaks down into another string from the same language (on the left) plus a suffix in a special example of recursion known as left recursion (on the right).


Q3. Name the data structures used by LL(1) parser. 

Ans. Data structures used by LL(1) parser are:

  • i. Input buffer 
  • ii. Stack 
  • iii. Parsing table

Q4. Give the data structures for shift reduce parser. 

Ans. Data structures for shift reduce parser are:

  • i. The input buffer storing the input string. 
  • ii. A stack for storing and accessing the L.H.S and R.H.S of rules. 

Q5. What are various types of LR parser? 

Ans. Various types of LRL parser are: 

  • i. SLR parser
  • ii. LALR parser 
  • iii. Canonical LR parser

Q6. Why do we need LR parsing table? 

Ans. To parse the input string using the shift-reduce approach, we require LR parsing tables.  


Q7. State limitation of SLR parser. 

Ans. Limitation of SLR parser are :

  • i. Since SLR grammars are a limited subset of CFG, SLR is less powerful than LR parser.
  • ii. The issue of many entries comes when reduction might not produce the rightmost preceding derivations.

Q8. Define left factoring.  

Ans. A grammar G is said to be left factored if any production of it is in no form of:

Define left factoring.

Q9. Define left recursion.  

Ans. A grammar G(V, T, P, S) is said to be left recursive if it has a production in the form of:  

Define left recursion. 

Unit-III: Syntax Directed Translation (Short Question)

Q1. What do you mean by Syntax Directed Definition (SDD) ?

Ans.  SDD is a generalization of CFG in which each grammar production X → 𝛂 is associated with a set of semantic rules of the form a = f(b1,b2,………….. bn) where a is an attribute obtained from the function f.


Q2. Define intermediate code. 

Ans. Intermediate code is a type of code produced during compilation that is extremely similar to machine code.


Q3. What are the various types of intermediate code representation ?

Ans. Different forms of intermediate code are:

  • i. Abstract syntax tree 
  • ii. Polish (prefix/postfix) notation 
  • iii. Three address code 

Q4. Define three address code. 

Ans. Three address code is an abstract form of intermediate code that can be implemented as a record with the address fields. The general form of three address code representation is : 

                                                                  a =b op c. 


Q5. What is postfix notations? 

Ans. Postfix notation is the type of notation in which operator are placed at the right end of the expression. For example, to add A and B, we can write as AB+ or BA+. 


Q6. Why are quadruples preferred over triples in an optimizing compiler?

Ans. 1. In an optimizing compiler, quadruples are preferred over triples because it can move instructions around.

2. The outcome of any given operation in the triples notation is referenced to by its position, thus if one instruction is relocated, modifications must be made to all references that lead to that result.


Q7. Give syntax directed translation for case statement.

Ans. 

Give syntax directed translation for case statement.

Q8.  What is a syntax tree ? Draw the syntax tree for the following statement: c b c b a – * + – * =

Ans. 1. In contrast to a parse tree, which includes unnecessary information, a syntax tree only displays the syntactic structure of a programme. 

2. Syntax tree is condensed form of the parse tree.  

Syntax tree of c b c b a – * + – * = : 

In the given statement, number of alphabets is less than symbols. So, the syntax tree drawn will be incomplete. 

What is a syntax tree ? Draw the syntax tree for the following statement: c b c b a - * + - * =

Q9. Define backpatching.

Ans. Backpatching is a procedure used in the code generation process to fill in blanks on labels with suitable semantic actions. Backpatching is done for: 

  • i. Boolean expressions 
  • ii. Flow of control statements 

Q10. Give advantages of SDD. 

Ans. SDD’s primary benefit is that it aids in selecting the evaluation order. The assessment of semantic SDDD operations may result in the generation of code, the saving of data to a symbol table, or the issuance of error signals. 


Q11. What are quadruples ?

Ans. Quadruples are structure with at most four fields such as op, arg1, arg2, result.  


Q12. Differentiate between quadruples and triples. 

Ans. 

S. No.QuadruplesTriples
1.Quadruple represent three address code by using four fields: OP, ARG1, ARG2, RESULT. Triples represent three address code by using three fields:OP, ARG1, ARG 2. 
2.Quadruple can perform code immovability during optimization.Triple faces the problem of code immovability during optimization. 

Unit-IV: Symbol Tables (Short Question)

Q1. Write down the short note on symbol table. 

Ans. A compiler uses a symbol table as a data structure to store details on the scope, life, and binding of names. The various programme elements, such as variables, constants, procedures, and the labels of statements, are identified by these names in the source code.


Q2. Describe data structure for symbol table. 

Ans. Data structures for symbol table are: 

  • 1. Unordered list 
  • 2. Ordered list 
  • 3. Search tree 
  • 4. Hash tables and hash functions

Q3. What is mean by activation record ? 

Ans. Activation record is a type of data structure that holds crucial state details for a certain function call instance. 


Q4. What is phase level error recovery ? 

Ans. By inserting references to error routines into the empty rows of the predictive parsing table, phase level error recovery is performed. These procedures have the ability to modify, add, or remove symbols from the input while displaying the proper error warnings. They could possibly fall out of the stack.


Q5. List the various error recovery strategies for a lexica analysis. 

Ans. Error recovery strategies are:

  • 1. Panic mode recovery
  • 2. Phrase level recovery 
  • 3. Error production 
  • 4. Global correction

Q6. What are different storage allocation strategies ?

Ans. Different storage allocation strategies are:

  • i. Static allocation 
  • ii. Stack allocation 
  • iii. Heap allocation

Q7. What do you mean by stack allocation ? 

Ans. The storage is arranged as a stack in a stack allocation approach. The control stack is another name for this stack. This stack uses push and pop operations to manage the available storage for local variables. 


Q8. Discuss heap allocation strategy. 

Ans. In order to store data objects during runtime, the heap allocation allocates and deallocates a continuous block of memory as needed.


Q9. Discuss demerit of heap allocation.  

Ans. The demerit of heap allocation is that it causes memory gaps during allocation.


Unit-V: Code Generation (Short Question)

Q1. What do you mean by code optimization ?

Ans. The approach employed by the compiler to improve the execution efficiency of the generated object code is referred to as code optimisation.


Q2. Define code generation.

Ans. Code generation is the process of developing assembly language/machine language statements that, when executed, accomplish the operations described by the source programme. The ultimate activity of a compiler is code generation. 


Q3. What are the various loops in flow graph ? 

Ans. Various loops in flow graph are: 

  • i. Dominators 
  • ii. Natural loops 
  • iii. Inner loops 
  • iv. Pre-header 
  • v. Reducible flow graph

Q4. Define DAG.

Ans.

  • 1. DAG is an abbreviation for Directed Acyclic Graph.
  • 2. DAGs are a good data structure for performing transformations on basic blocks.
  • 3. A DAG depicts how the value generated by each statement in the basic block is used in the block’s subsequent statement.

Q5. Write applications of DAG.  

Ans. The DAG is used in: 

  • i. Identifying common sub-expressions.
  • ii. Deciding which names are utilized inside and outside the computed block.
  • iii. Identifying which block statements may have value outside of the block. computed
  • iv. Simplifying the quadruple list by removing common sub-expressions.

Q6. What is loop optimization ? What are its methods ?  

Ans. Loop optimization is a technique in which code optimization is performed on inner loops. The loop optimization is carried out by following methods: 

  • i. Code motion 
  • ii. Induction variable and strength reduction 
  • iii. Loop invariant method 
  • iv. Loop unrolling 
  • v. Loop fusion

Q7. What are various issues in design of code generation ?

Ans. Various issues in design of code generation are:

  • i. Input to the code generator 
  • ii. Target programs 
  • iii. Memory management 
  • iv. Instruction selection 
  • v. Register allocation 
  • vi. Choice of evaluation order 
  • vii. Approaches to code generation

Q8. List out the criteria for code improving transformations.

Ans. Criteria for code improving transformations are : 

  • 1. A transformation must preserve meaning of a program. 
  • 2. A transformation must improve program by a measurable amount on average. 
  • 3. A transformation must worth the effort.   

Q9. What is the use of algebraic identities in optimization of basic blocks ?

Ans. Uses of algebraic identities in optimization of basic blocks are:

  • 1. Using the strength reduction technique, the algebraic transformation may be produced.
  • 2. The algebraic transformations can be achieved using the constant folding technique.
  • 3. To execute algebraic transformations on fundamental blocks, employ common sub-expression elimination, associativity, and commutativity.

Q10. Discuss the subset construction algorithm. 

Ans.

  • 1. A subset creation algorithm is an algorithm that partitions algorithms into subsets by locating the algorithm’s leader.
  • 2. A leader is the target element of conditional or unconditional goto.
  • 3. Begin at the leader and end right before the leader statement to build the basic block.

Q11. How to perform register assignment for outer loops ? 

Ans. Global register allocation first allocates registers for variables in inner loops because that is where a programme spends the most of its time, and the same register is utilized for variables if they appear in an outer loop.


Q12. What is meant by viable prefixes ?

Ans. Viable prefixes are right sentential form prefixes that can appear on the stack of a shift-reduce parser.


Q13. Define peephole optimization. 

Ans. Peephole optimisation is a type of code optimisation that only affects a small portion of the code. It is used to a very tiny collection of instructions in a code segment. Peephole refers to the limited set of instructions or small portion of code on which peephole optimisation is conducted. 


Q14. What is dangling else problem?

Ans. The dangling else problem is caused by the fact that the compiler always associates a ‘else’ with the immediately previous if, resulting in ambiguity. This issue develops in a nested if statement where the number of ifs exceeds the number of else clauses.


bachelor exam preparation all question paper with solution important questions with solution

Compiler Design Btech Quantum PDF, Syllabus, Important Questions

LabelLink
Subject SyllabusSyllabus
Short QuestionsShort-question
Question paper – 2021-222021-22

Compiler Design Quantum PDF | AKTU Quantum PDF:

Quantum SeriesLinks
Quantum -2022-232022-23

AKTU Important Links | Btech Syllabus

Link NameLinks
Btech AKTU CircularsLinks
Btech AKTU SyllabusLinks
Btech AKTU Student DashboardStudent Dashboard
AKTU RESULT (One VIew)Student Result

Important Links-Btech (AKTU)

LabelLinks
Btech InformationInfo Link
Btech BranchLINK
Quantum-PageLink

2 thoughts on “Compiler Design KCS-502/KIT-052 Aktu Btech Short Question, Notes Pdf”

Leave a Comment