Compiler Quiz 2 (III Cse C)

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Sruthi M
S
Sruthi M
Community Contributor
Quizzes Created: 1 | Total Attempts: 548
| Attempts: 548 | Questions: 30
Please wait...
Question 1 / 30
0 %
0/100
Score 0/100
1. An intermediate code form is

Explanation

The correct answer is "All of these" because an intermediate code form can be represented in postfix notation, syntax trees, and three address code. Postfix notation is a way of representing mathematical expressions where the operators are placed after their operands. Syntax trees are graphical representations of the structure of a program's source code. Three address code is a low-level programming language that uses three operands per instruction. Therefore, all of these options are valid intermediate code forms.

Submit
Please wait...
About This Quiz
Compiler Quiz 2 (III Cse C) - Quiz

COMPILER QUIZ 2 (III CSE C) assesses knowledge in compiler design, focusing on address codes, intermediate code forms, flow graphs, code optimizations, and control-flow-graph analysis. It's designed for third-year computer science students, enhancing understanding of compiler structures and optimization techniques.

Personalize your quiz and earn a certificate with your name on it!
2. An intermediate code form is

Explanation

The correct answer is "All of the mentioned" because an intermediate code form can be represented in various ways, including post-fix notation, syntax trees, and three address code. All of these forms are commonly used in compilers and programming languages to represent the intermediate code generated during the compilation process. Therefore, all the options mentioned are valid representations of intermediate code.

Submit
3. Consider the intermediate code given below: 1. i = 1 2. j = 1 3. t1 = 5 * i 4. t2 = t1 + j 5. t3 = 4 * t2 6. t4 = t3 7. a[t4] = –1 8. j = j + 1 9. if j <= 5 goto(3) 10. i = i + 1 11. if i < 5 goto(2) The number of nodes and edges in the control-flow-graph constructed for the above code, respectively, are

Explanation

The given intermediate code represents a loop structure where the statements inside the loop are executed multiple times until the condition is met. The control-flow-graph is a graphical representation of the flow of control in the code. In this case, there are two loops, one nested inside the other. Each loop contributes one node to the control-flow-graph. Additionally, there are other statements outside the loops that contribute to the nodes as well. Therefore, the total number of nodes is 6. The edges in the control-flow-graph represent the flow of control between different nodes. Since there are multiple branches and loops in the code, there are a total of 7 edges in the control-flow-graph.

Submit
4. Principal methods of representing the value of boolean expression

Explanation

The correct answer is "all of the above" because all three methods mentioned - encoding true & false numerically, evaluating boolean expression analogously to an arithmetic expression, and implementing boolean expression by flow of control - are valid and commonly used ways of representing the value of boolean expressions. Each method has its own advantages and is suitable for different scenarios. Therefore, the correct answer is that all of these methods can be used to represent the value of boolean expressions.

Submit
5. A parse tree showing the value of attributes at each node

Explanation

An annotated parse tree is a parse tree that includes additional information or attributes at each node. This additional information can represent the value of attributes associated with each node, such as type information or semantic meaning. Therefore, an annotated parse tree can be considered as a type of parse tree that shows the value of attributes at each node.

Submit
6. Boolean expressions have following purposes

Explanation

Boolean expressions have two main purposes: computing logical values and being used as conditional expressions. "Computing logical values" means that boolean expressions can evaluate to either true or false based on the values of the variables involved. "Used as conditional expressions" means that boolean expressions can be used to determine whether a certain condition is true or false, and based on that, execute different parts of a program. Therefore, the correct answer is "both a & b" because boolean expressions serve both of these purposes.

Submit
7. A basic block can be analyzed by

Explanation

A basic block can be analyzed by a DAG (Directed Acyclic Graph) because a DAG represents the dependencies and relationships between the instructions in the basic block without any cycles. This allows for efficient analysis and optimization of the basic block's instructions. A flow graph and a graph with cycles may not accurately represent the dependencies and relationships within a basic block, making them less suitable for analysis. Therefore, the correct answer is DAG.

Submit
8. In compiler terminology reduction in strength means

Explanation

Reduction in strength in compiler terminology refers to the process of replacing a costly operation with a relatively cheaper one. This optimization technique aims to improve the efficiency of the compiled code by replacing expensive computations with less expensive alternatives. By doing so, the overall performance of the program can be enhanced, as the execution time is reduced. This technique is particularly useful in situations where the same result can be achieved using a less resource-intensive operation.

Submit
9. Substitution of values for names (whose values are constants) is done in  

Explanation

Constant folding is the process of evaluating constant expressions at compile time instead of runtime. In this process, values for names that are constants are substituted with their actual values. This optimization technique helps in reducing the number of instructions and improving the efficiency of the program. Therefore, the substitution of values for names (whose values are constants) is done in constant folding.

Submit
10. __________can be used to generate code for Boolean expressions and flow of-control statements in one pass.

Explanation

Backpatching is a technique used in code generation where temporary placeholders, called "backpatching points," are inserted into the code. These placeholders are later filled with the actual addresses or labels during a second pass. This allows the code generator to handle Boolean expressions and flow-of-control statements in a single pass, as it can defer the resolution of addresses or labels until all necessary information is available. This technique improves efficiency and simplifies the code generation process.

Submit
11. Listing    pointers    to    triples,    rather    than    listing    triples    themselves    is   implementation of

Explanation

Indirect Triple is an implementation technique where instead of directly listing the triples themselves, pointers to the triples are listed. This approach helps in reducing the memory space required to store the triples and improves the efficiency of the implementation. By using pointers, we can easily access and manipulate the triples when needed. This technique is commonly used in compiler design and optimization.

Submit
12. The size field of activation record can be determined at

Explanation

The size field of an activation record, which contains information about the variables and parameters of a function, can be determined at both runtime and compile time. At compile time, the compiler can analyze the code and calculate the size of the activation record based on the variables and their types. At runtime, if the code includes dynamic memory allocation or variable-length arrays, the size of the activation record may need to be determined dynamically. Therefore, the size field of an activation record can be determined at both compile time and runtime.

Submit
13. A pictorial representation of the value computed by each statement in the basic block is

Explanation

The correct answer is DAG. A Directed Acyclic Graph (DAG) is a pictorial representation that can be used to represent the value computed by each statement in a basic block. It is a graph that consists of nodes representing statements and edges representing dependencies between the statements. The DAG is acyclic, meaning there are no cycles or loops in the graph. This representation is commonly used in compiler optimization techniques to analyze and optimize code.

Submit
14. The address code involves

Explanation

The given answer suggests that the address code may involve up to three addresses, but it does not necessarily have to use all three. This means that the code can have one, two, or three addresses, but not more than three. Additionally, the answer states that there are no unary operators involved in the address code.

Submit
15. The method which merges the bodies of two loops is

Explanation

Loop jamming is the method that merges the bodies of two loops. It involves combining the code of two separate loops into a single loop, thereby reducing the number of iterations and improving efficiency. This technique is commonly used in loop optimization to eliminate redundant code and improve the performance of the program. Constant folding, loop rolling, and none of these do not involve merging loop bodies, making them incorrect choices.

Submit
16. Consider the following code segment.   x = u - t; y = x * v; x = y + w; y = t - z; y = x * y; The minimum number of total variables required to convert the above code segment to static single assignment form is 

Explanation

not-available-via-ai

Submit
17. The graph that shows basic blocks and their successor relationship is called

Explanation

A flow graph is a graph that represents the control flow of a program by showing the basic blocks and their successor relationships. Each basic block represents a sequence of instructions that are executed together. The successor relationships indicate the order in which the basic blocks are executed. Therefore, a flow graph is the correct term to describe the graph that shows basic blocks and their successor relationship.

Submit
18. The graph that shows basic blocks and their successor relationship is called

Explanation

A flow graph is a graphical representation of a program's control flow, where each basic block represents a sequence of instructions and the edges represent the flow of control between these blocks. It shows the successor relationship between the basic blocks, indicating the order in which they are executed. Therefore, a flow graph is the correct term for the graph that shows basic blocks and their successor relationship.

Submit
19. Input to code generator

Explanation

The given options are different stages in the process of code generation. The source code is the original code written by the programmer, the target code is the final code that is executed by the computer, and the intermediate code is an intermediate representation of the code that is used in the compilation process. Out of these options, the intermediate code is the most suitable answer as it represents a stage in the code generation process.

Submit
20. Consider the following C code segment.   for (i = 0, i { for (j=0; j { if (i%2) { x += (4*j + 5*i); y += (7 + 4*j); }} } Which one of the following is false?

Explanation

The given code segment does not contain any dead code, which means that all the code within the loops is necessary for the program's functionality. Therefore, there is no scope for dead code elimination in this code.

Submit
21. Local and loop optimization in turn provide motivation for 

Explanation

Local and loop optimization are techniques used to improve the efficiency of code by optimizing specific sections or loops. These optimizations can identify redundant operations, eliminate unnecessary computations, and improve memory access patterns. Data flow analysis is a technique that analyzes how data is used and propagated throughout the program. It can identify dependencies and determine the optimal ordering of operations. Therefore, data flow analysis is motivated by local and loop optimization as it provides valuable insights into the data dependencies and allows for further optimization opportunities. Constant folding and peephole optimization are also optimization techniques, but they are not directly related to the motivation behind data flow analysis.

Submit
22. Quadruple is a record structure with four fields

Explanation

The correct answer is "Op, arg1, arg2 and result". This is because the question is asking for the fields that are present in a Quadruple record structure. The given options include different combinations of fields, but only the option "Op, arg1, arg2 and result" includes all four fields mentioned in the question. Therefore, this is the correct answer.

Submit
23. An optimizing compiler 

Explanation

An optimizing compiler is designed to improve the performance of the compiled code by making it occupy less space, take less time for execution, and optimize the code itself. This means that it aims to reduce the memory footprint of the compiled program, make it run faster, and optimize the code structure and logic to enhance efficiency. Therefore, all of the given options accurately describe the purpose and capabilities of an optimizing compiler.

Submit
24. The optimization technique which is typically applied on loops is

Explanation

The optimization technique that is typically applied on loops is known as "All of these." This means that all of the mentioned techniques (removal of invariant computation, peephole optimization, and constant folding) are commonly used to optimize loops. These techniques aim to improve the efficiency and performance of loops by eliminating redundant computations, optimizing code at a small scale, and evaluating constant expressions during compilation.

Submit
25. Peephole optimization is form of

Explanation

Loop optimization is the correct answer because peephole optimization is a specific type of optimization technique that focuses on improving the efficiency of code within loops. It analyzes and modifies code at a small scale, typically within a fixed window of instructions known as a "peephole." This technique aims to eliminate redundant or unnecessary instructions, rearrange code for better performance, and optimize loop structures. Therefore, loop optimization is the most appropriate category for peephole optimization.

Submit
26. Consider the following source code :   c = a + b d = c c = c – e a = d – e b = b * e b = d/b Which of the following is correct optimization of given code?

Explanation

The correct optimization of the given code is the third option. This is because it minimizes the number of operations and unnecessary assignments. By assigning c = a + b first, we can reuse the value of c in the subsequent calculations. Then, we assign d = c to store the value of c before it is updated. Next, we update c by subtracting e from it. After that, we update a by subtracting e from d. Finally, we update b by multiplying it with e and then dividing d by b. This optimization reduces the number of redundant calculations and assignments.

Submit
27. Some code optimizations are carried out on the intermediate code because

Explanation

The reason why some code optimizations are carried out on the intermediate code is because it enhances the portability of the compiler to other target processors. By optimizing the intermediate code, the compiler can generate efficient machine code that can be executed on different processors without the need for extensive modifications. This allows the compiler to be more versatile and adaptable to different hardware architectures, making it easier to port the compiler to different platforms.

Submit
28. In activation tree each node represent

Explanation

The correct answer is "activation of a procedure". In an activation tree, each node represents the activation of a procedure. This means that each node represents the execution of a specific procedure within the main program. The activation of a procedure includes the allocation of memory for local variables, the execution of the procedure's code, and the management of the procedure's return value. Therefore, the activation tree provides a visual representation of the flow of control and the hierarchy of procedure invocations within a program.

Submit
29. Syntax directed translation scheme is desirable because

Explanation

A syntax directed translation scheme is desirable because it is easy to modify. This means that if there are any changes or updates needed in the translation scheme, it can be easily done without affecting the overall implementation or description. This flexibility allows for efficient and hassle-free modifications, making the syntax directed translation scheme a desirable choice.

Submit
30. The identification of common sub-expression and replacement of run-time computations by compile-time computations is

Explanation

Constant folding is the process of simplifying expressions at compile-time by evaluating them to a constant value. This optimization technique is used to identify common sub-expressions and replace them with their computed values, reducing the need for runtime computations. By performing constant folding, the compiler can optimize the code by eliminating redundant calculations and improving the overall efficiency of the program. Therefore, constant folding is the correct answer in this context.

Submit
View My Results

Quiz Review Timeline (Updated): Mar 14, 2023 +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Mar 14, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Mar 12, 2019
    Quiz Created by
    Sruthi M
Cancel
  • All
    All (30)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
An intermediate code form is
An intermediate code form is
Consider the intermediate code given below: ...
Principal methods of representing the value of boolean expression
A parse tree showing the value of attributes at each node
Boolean expressions have following purposes
A basic block can be analyzed by
In compiler terminology reduction in strength means
Substitution of values for names (whose values are constants) is done...
__________can be used to generate code for Boolean expressions and...
Listing    pointers   ...
The size field of activation record can be determined at
A pictorial representation of the value computed by each statement in...
The address code involves
The method which merges the bodies of two loops is
Consider the following code segment. ...
The graph that shows basic blocks and their successor relationship is...
The graph that shows basic blocks and their successor relationship is...
Input to code generator
Consider the following C code segment. ...
Local and loop optimization in turn provide motivation for 
Quadruple is a record structure with four fields
An optimizing compiler 
The optimization technique which is typically applied on loops is
Peephole optimization is form of
Consider the following source code : ...
Some code optimizations are carried out on the intermediate code...
In activation tree each node represent
Syntax directed translation scheme is desirable because
The identification of common sub-expression and replacement of...
Alert!

Advertisement