0% found this document useful (0 votes)
24 views4 pages

Bits

Uploaded by

vavinash120
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views4 pages

Bits

Uploaded by

vavinash120
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

1. Which of the following is the primary goal of code optimization in compiler design?

A. To reduce the size of the source code


B. To improve the efficiency of the code generated
C. To improve the readability of the code
D. To detect and remove syntax errors

2. Which of the following types of grammars are associated with regular languages?
A) Type 0 B) Type 1 C) Type 2 D) Type 3

3. Which of the following is NOT a type of optimization in a compiler?

A. Machine-level optimization
B. Peephole optimization
C. Loop optimization
D. Syntax optimization

4. Which of the following is true about a Type 0 grammar?


A) It generates regular languages. B) It can generate context-sensitive languages.
C) It can generate recursively enumerable languages. D) It can generate context-free languages.

5. Which of the following is NOT typically considered a part of semantic analysis in NLP?

A) Word Sense Disambiguation


B) Named Entity Recognition
C) Syntactic Parsing
D) Sentiment Analysis
6. Which phase of the compiler performs type checking?
A) Lexical analysis B) Syntax analysis C) Semantic analysis D) Code generation
7. Which of the following optimizations eliminates instructions that have no effect on the program
output?
A. Loop unrolling
B. Dead code elimination
C. Constant propagation
D. Inlining
8. What is "type coercion"?
A) method used in dynamic languages to enforce static typing.
B) The automatic conversion of one data type into another during type checking.
C) The explicit conversion of one type to another by the programmer.
D) The process of assigning the correct type to variables during initialization.

9. Which optimization technique is used to minimize the number of instructions that access memory?

A. Loop interchange
B. Common subexpression elimination
C. Loop fusion
D. Register allocation

10.What is the primary goal of runtime storage management in a compiler?


A) To generate machine code
B) To manage the allocation and deallocation of memory during program execution
C) To optimize the source code D) To detect semantic errors in the program

11. Which of the following is an example of a control-flow optimization technique?

A. Constant folding
B. Dead code elimination
C. Loop-invariant code motion
D. Instruction scheduling

12. In heap-based memory allocation, the memory is:


A) Automatically deallocated when a function call returns. B) Allocated for global variables.
C) Allocated and deallocated manually by the programmer. D) Allocated dynamically at
compile time.

13. Which of the following is the primary purpose of loop unrolling?

A. To increase the size of the loop body and reduce the number of iterations
B. To remove unnecessary loop conditions
C. To merge multiple loops into a single loop
D. To eliminate redundant code in loops

14. Which of the following storage areas is typically used for storing function call information,
including local variables and function parameters?

A) The heap B) The stack C) The data segment D) The text segment

15. In which phase of the compiler is intermediate code translated into machine code?

A. Lexical Analysis
B. Syntax Analysis
C. Code Optimization
D. Code Generation

16. Which of the following is responsible for managing memory during program execution?
A) Compiler front-end B) Compiler back-end C) Operating system D) Runtime system

17. The primary purpose of code generation in a compiler is to:

A. Translate the intermediate representation into machine-level code


B. Perform optimizations to improve execution time
C. Parse the syntax of the source code
D. Analyze the control flow of the program
18. Constant folding is a technique used in optimization to:
A) Simplify expressions involving constant values at compile-time.
B) Eliminate loops that iterate a constant number of times.
C) Merge consecutive variables that have constant values.
D) Replace variables with their constant values at runtime.

19. Which of the following is generated in the intermediate code generation phase of a compiler?

A. Assembly code
B. Object code
C. High-level programming language code
D. Intermediate code (such as Three-address code)

20. Dead code elimination refers to the process of:


A) Removing code that is never executed or has no effect on the program’s output.
B) Removing code that is executed but contains errors.
C) Combining similar expressions to reduce redundancy.
D) Rewriting the code to remove syntactic redundancies.

21. In the code generation phase, register allocation refers to:

A. Assigning variables to registers to minimize memory access time


B. Allocating memory for the program's data
C. Generating code for loading and storing values in registers
D. Assigning labels to different code blocks

22. Which of the following techniques can help to eliminate redundant calculations in a program?

A) Code hoisting B) Loop unrolling C) Common subexpression elimination D) Strength reduction

23. Data flow analysis can be used in compiler optimization to:

A) Improve code readability B) Identify unnecessary computations or dead code.


C) Detect syntax errors. D) Improve memory management techniques.

24. A basic block in compiler design is defined as:

A) A block of memory used for storing intermediate code.


B) A sequence of instructions with only one entry and one exit point.
C) A function or procedure in the program. D) A control flow structure containing loops.

25. In the context of basic blocks, control flow refers to:

A) The flow of data between variables within a block.


B) The direction in which the program execution proceeds from one basic block to another.
C) The arrangement of instructions within a block. D) The allocation of memory for each basic block.
26. In a program’s control flow graph (CFG), a basic block is represented as:

A) A single node. B) A set of edges connecting other basic blocks.


C) A directed graph of instructions. D) A subgraph containing only the start and end points of loops.

27. The primary goal of the code generation phase in a compiler is to:

A) Optimize the program for better performance.


B) Translate intermediate code into machine code or assembly language.
C) Ensure that the program adheres to the correct syntax.
D) Identify semantic errors in the program.

28. Which of the following is NOT typically a part of the code generation phase?

A) Register allocation B) Instruction selection C) Syntax checking D) Code emission

29. In compiler design, a Directed Acyclic Graph (DAG) is used to represent:

A)The program’s syntax tree. B) The sequence of memory locations.


C) The control flow of the program. D) The flow of expressions and their evaluations.

30. Which type of instruction is commonly used in a three-address code representation in intermediate
code generation?

A. Load and store instructions


B. Arithmetic instructions involving two operands
C. Unary operations
D. Instructions with three operands (e.g., x = y + z)

31. In the context of DAG in compiler design, what does each node typically represent?
A) An operand or a result of a computation. B) A variable that holds the result of an expression.
C) A function or method in the program. D) A basic block of the program.
32. Which of the following automata is capable of recognizing context-free languages (Type 2)?
A) Finite automaton B) Turing machine C) Pushdown automaton D) Linear-bounded automaton

You might also like