WorksheetsCompiler Design Worksheet MCQs
Total questions: 15
Worksheet time: 8mins
Which data structure allows efficient insertion and lookup in a symbol table for compilers?
Linked List
Hash Table
Binary Tree
Array
In block-structured languages, symbol tables are usually managed using:
Queue of tables
Stack of tables
Tree of tables
Array of tables
What does a symbol table not store?
Variable names
Data types
Intermediate code
Memory locations
When two identifiers hash to the same slot, the situation is handled using:
Separate chaining
Linear regression
Recursive parsing
Direct mapping
In Syntax Directed Translation, the semantic rules are associated with:
Tokens
Grammar productions
Intermediate code
Symbol table
An S-attributed definition contains only:
Synthesized attributes
Inherited attributes
Dynamic attributes
None of the above
An L-attributed definition can contain:
Only synthesized attributes
Both synthesized and certain inherited attributes
Only inherited attributes
None
Which optimization replaces variables with known constant values?
Constant folding
Constant propagation
Dead code elimination
Loop unrolling
Which of the following expressions can be folded at compile time?
x + y
3 + 5
a + 2
p * q
Constant propagation cannot be applied if:
Variable is assigned once
Variable is assigned inside a loop
Variable is global
Variable is used after assignment
Constant propagation uses which type of data flow analysis?
Forward flow
Backward flow
Lateral flow
Bidirectional
PRE aims to:
Eliminate all redundant computations
Eliminate only partially redundant expressions
Eliminate loop-invariant computations
Remove dead code
An expression is partially redundant if:
It occurs on every path
It occurs on no path
It occurs on some but not all paths
It occurs only once
How does PRE differ from common subexpression elimination (CSE)?
PRE handles loops
PRE removes all redundancies
PRE works across paths
CSE is more general
PRE typically operates on:
Lexical tokens
Parse trees
Basic blocks
Symbol tables
