All questions of Intermediate Code Generation for Computer Science Engineering (CSE) Exam

Which of these does not belong to CFG?
  • a)
    Terminal Symbol
  • b)
    Non terminal Symbol
  • c)
    Start symbol
  • d)
    End Symbol
Correct answer is option 'D'. Can you explain this answer?

Mansi Shah answered
Explanation:

A context-free grammar (CFG) is a formal grammar used to describe the syntax of a programming language or other formal languages. It consists of a set of production rules that specify how symbols can be combined to form strings.

Terminal Symbol:
Terminal symbols are the basic building blocks of a language. They are the smallest units of a language that cannot be further divided. Terminal symbols represent the actual words or symbols that appear in the language. For example, in the context of a programming language, terminal symbols can represent keywords, operators, identifiers, literals, etc.

Non-terminal Symbol:
Non-terminal symbols are placeholders that represent groups of terminal symbols. They are used to define the structure of the language. Non-terminal symbols do not appear directly in the final language, but they are used in the production rules to specify how terminal symbols can be combined. For example, non-terminal symbols can represent expressions, statements, functions, etc.

Start Symbol:
The start symbol is a special non-terminal symbol that represents the beginning of the language. It is used to indicate where the derivation of a string should start. The start symbol is typically the left-hand side of the first production rule.

End Symbol:
Unlike the other three symbols, there is no concept of an "end symbol" in the context of a CFG. A CFG describes the structure of a language, but it does not specify how a string ends. The end of a string is typically determined by the specific language or parser that is used to process the string.

Therefore, the correct answer is option 'D' (End Symbol) as it does not belong to the context-free grammar.

 A non relocatable program is the one which
  • a)
    Cannot execute in any area of storage other than the one designated
  • b)
    Consists of a program and information for its relocation
  • c)
    None of the mentioned
  • d)
    All of the mentioned
Correct answer is option 'A'. Can you explain this answer?

Divya Kaur answered
Explanation:

Non-relocatable Program:
A non-relocatable program is a program that cannot execute in any area of storage other than the one designated. This means that the program is loaded into a specific memory location and cannot be moved to another location for execution.

Characteristics of Non-relocatable Program:
- Fixed Memory Location: Non-relocatable programs are designed to run from a specific memory location and cannot be relocated to another location for execution.
- No Information for Relocation: Unlike relocatable programs, non-relocatable programs do not contain any information for their relocation to different memory locations.
- Restricted Execution: These programs are limited to executing only in the designated memory location and cannot be run from any other location.

Advantages and Disadvantages:
- Advantages: Non-relocatable programs provide a secure and controlled environment for execution, as they are confined to a specific memory location.
- Disadvantages: The main disadvantage of non-relocatable programs is that they lack flexibility, as they cannot be moved to different memory locations for efficient memory management.
In conclusion, a non-relocatable program is designed to run from a fixed memory location and does not have the capability to execute in any other area of storage. It is important for ensuring security and control over program execution, but it may limit flexibility in memory management.

Relocating bits used by relocating loader are specified by
  • a)
    Relocating loader itself
  • b)
    Linker
  • c)
    Assembler
  • d)
    Macro Processor
Correct answer is option 'B'. Can you explain this answer?

Kiran Mehta answered
Relocating bits used by relocating loaders are specified by the linker.

Explanation:
A relocating loader is a program that loads an object program into memory for execution. It is responsible for allocating memory, resolving external references, and performing relocations. Relocations involve adjusting the memory addresses in the object program to match the actual memory locations where the program will be loaded.

When a program is compiled, it may contain references to external symbols, such as functions or variables, that are defined in other modules or libraries. These references are usually represented as symbolic addresses or offsets. However, these addresses are not fixed because the program can be loaded at different memory locations each time it is executed.

To resolve these external references and perform relocations, the relocating loader uses information provided by the linker. The linker is a program that combines multiple object files and libraries into a single executable file. It resolves symbols, calculates addresses, and generates relocation information.

The relocation information specifies the locations in the object program where adjustments need to be made. It contains the addresses or offsets that need to be modified to reflect the actual memory locations. The relocating loader uses this information to update the object program before loading it into memory.

Therefore, it is the linker's responsibility to specify the relocating bits used by the relocating loader. The linker analyzes the object files, resolves symbols, and generates relocation entries based on the memory layout and the addresses of external symbols. These relocation entries are then used by the relocating loader to perform the necessary adjustments during the loading process.

In conclusion, the linker is responsible for specifying the relocating bits used by the relocating loader. It generates relocation information based on the object files and libraries being linked, which is then used by the relocating loader to perform relocations and ensure correct execution of the program.

The construction of the canonical collection of the sets of LR (1) items are similar to the construction of the canonical collection of the sets of LR (0) items. Which is an exception?
  • a)
    Closure and goto operations work a little bit different
  • b)
    Closure and goto operations work similarly
  • c)
    Closure and additive operations work a little bit different
  • d)
    Closure and associatively operations work a little bit different.
Correct answer is option 'A'. Can you explain this answer?

Dipika Chavan answered
Understanding LR(1) Items
The construction of canonical collections for LR(1) items indeed resembles that for LR(0) items, but there are key differences particularly in the closure and goto operations.

Key Differences Between LR(0) and LR(1)
- **Closure Operation**:
- In LR(0), the closure operation collects items based solely on the production rules.
- In LR(1), the closure must also consider the lookahead symbol. This means that when a non-terminal is expanded, we need to include items that can be derived with a specific lookahead, making the closure operation more complex.
- **Goto Operation**:
- The goto operation in LR(0) transitions to the next state based purely on the input symbols.
- In LR(1), the goto operation not only transitions based on the input but must also maintain the lookahead context. This ensures that the parser can accurately determine the next state based on both the current item and the lookahead symbol.

Conclusion
The correct answer to the question is option 'A' because the closure and goto operations in LR(1) items differ from their LR(0) counterparts primarily due to the necessity of incorporating lookahead symbols. This additional complexity is what sets LR(1) apart, making the parsing process more precise and capable of handling a broader range of grammars.

 Grammar that produce more than one Parse tree for same sentence is
  • a)
    Ambiguous
  • b)
    Unambiguous
  • c)
    Complementary
  • d)
    Concatenation Intersection
Correct answer is option 'A'. Can you explain this answer?

Anirban Khanna answered
An ambiguous grammar is one for which there is more than one parse tree for a single sentence. Since each parse tree corresponds to exactly one leftmost (or rightmost) derivation, an ambiguous grammar is one for which there is more than one leftmost (or rightmost) derivation of a given sentence.

The graph that shows basic blocks and their successor relationship is called
  • a)
    Dag
  • b)
    Flow Graph
  • c)
    Control Graph
  • d)
    Hamilton Graph
Correct answer is option 'B'. Can you explain this answer?

Understanding Flow Graphs
A Flow Graph is an essential concept in computer science, particularly in the analysis and optimization of programs. It represents the control flow within a program by showing how basic blocks of code are interconnected. Here’s a breakdown of its significance:
What is a Basic Block?
- A basic block is a sequence of instructions that executes linearly without any jumps or branches.
- Each block begins with a single entry point and ends with a single exit point.
Successor Relationship
- The successor relationship in a flow graph indicates which basic blocks can be executed after a given block.
- This is crucial for understanding how control flows through the program, especially in scenarios involving loops and conditional statements.
Significance of Flow Graphs
- Optimization: Flow graphs are used in compiler optimizations to enhance the efficiency of the generated code.
- Control Structures: They help visualize complex control structures like loops, conditionals, and function calls.
- Analysis: Flow graphs enable static analysis of programs, identifying unreachable code and potential bugs.
Comparison with Other Graph Types
- DAG (Directed Acyclic Graph): Unlike flow graphs, DAGs do not allow cycles, making them unsuitable for representing control flow with loops.
- Control Graph: While often used interchangeably, flow graphs specifically focus on execution paths rather than general relationships.
- Hamilton Graph: This type of graph pertains to specific paths that visit every vertex exactly once, which is unrelated to control flow representation.
In summary, the correct answer is option 'B' because a flow graph effectively captures the basic blocks and their successor relationships, providing a clear representation of the program's control flow.

A relocatable program form is one which
  • a)
    Cannot execute in any area of storage other than the one designated
  • b)
    Consists of a program and information for its relocation
  • c)
    None of the mentioned
  • d)
    All of the mentioned
Correct answer is option 'C'. Can you explain this answer?

A relocatable program form is one which consists of a program and relevant information for its relocation. Using this information it is possible to relocate the program to execute from a storage area then the one designated for it at the time of its coding or translation.

 An optimizer Compiler
  • a)
    Is optimized to occupy less space
  • b)
    Both of the mentioned
  • c)
    Optimize the code
  • d)
    None of the mentioned
Correct answer is option 'D'. Can you explain this answer?

Rajveer Sharma answered
Understanding Compiler Optimizers
Compilers play a crucial role in converting high-level programming languages into machine code. Among their various functions, optimizers are essential for enhancing performance and efficiency. However, the given answer, option 'D' (None of the mentioned), suggests a misunderstanding of the role of compiler optimizers.
Functions of Compiler Optimizers
- Code Optimization: Optimizers improve the performance of the code by making it run faster or consume less memory. They may eliminate redundant calculations or simplify expressions.
- Space Optimization: While some optimizers do indeed aim to reduce the size of the generated code, not all optimizers prioritize this. The focus can vary based on the optimization level and target environment.
- Performance Enhancement: The primary goal of many optimizers is to enhance execution speed, which may not always correlate with reduced memory usage.
Why 'None of the mentioned' is Incorrect
- The question implies that optimizers exclusively aim at occupying less space or both. This is misleading because optimizers can serve multiple goals, including performance and space efficiency.
- While option 'D' suggests that compiler optimizers do not focus on space or performance optimization, this is inaccurate. They often work on multiple fronts simultaneously or selectively, depending on the requirements.
Conclusion
In summary, compiler optimizers are designed to improve various aspects of code, including speed and memory usage. The selection of optimization techniques depends on the context and specific goals of the compilation process. Thus, the correct answer should acknowledge the multifaceted role of optimizers rather than dismiss their capabilities entirely.

 A series of statements explaining how the data is to be processed is called
  • a)
    Assembly
  • b)
    Machine
  • c)
    COBOL
  • d)
    Program
Correct answer is option 'D'. Can you explain this answer?

Abhay Ghoshal answered
 A program is a sequence of instructions, written to perform a task by computer. It requires programs to function, typically executing the program’s instructions in a central processor.

A self-relocating program is one which
  • a)
    Cannot execute in any area of storage other than the one designated
  • b)
    Consists of a program and information for its relocation
  • c)
    None of the mentioned
  • d)
    All of the mentioned
Correct answer is option 'C'. Can you explain this answer?

Nabanita Basak answered
A self-relocating program is a program which can perform the relocation itself
•A table of information about address sensitive instruction in the program.
•Relocating logic that can perform the relocation of the address sensitive instructions.

A top down parser generates
  • a)
    Rightmost Derivation
  • b)
    Right most derivation in reverse
  • c)
    Left most derivation
  • d)
    Left most derivation in reverse
Correct answer is option 'C'. Can you explain this answer?

Bijoy Iyer answered
Top-down parsing is a parsing strategy where one first looks at the highest level of the parse tree and works down the parse tree by using the rewriting rules of a formal grammar.

The linker
  • a)
    Is similar to interpreter
  • b)
    Uses source code as its input
  • c)
    Is required to create a load module
  • d)
    None of the mentioned
Correct answer is option 'C'. Can you explain this answer?

Arka Dasgupta answered
It is a program that takes one or more object files generated by a compiler and combines them into a single executable file, library file, or another object file.

Chapter doubts & questions for Intermediate Code Generation - 6 Months Preparation for GATE CSE 2025 is part of Computer Science Engineering (CSE) exam preparation. The chapters have been prepared according to the Computer Science Engineering (CSE) exam syllabus. The Chapter doubts & questions, notes, tests & MCQs are made for Computer Science Engineering (CSE) 2025 Exam. Find important definitions, questions, notes, meanings, examples, exercises, MCQs and online tests here.

Chapter doubts & questions of Intermediate Code Generation - 6 Months Preparation for GATE CSE in English & Hindi are available as part of Computer Science Engineering (CSE) exam. Download more important topics, notes, lectures and mock test series for Computer Science Engineering (CSE) Exam by signing up for free.

Top Courses Computer Science Engineering (CSE)