Q. Which of the following statements about intermediate code is true?
-
A.
It is always in a high-level programming language
-
B.
It is specific to the target architecture
-
C.
It can be optimized before final code generation
-
D.
It is not used in modern compilers
Solution
Intermediate code can be optimized before final code generation, allowing for better performance on the target architecture.
Correct Answer:
C
— It can be optimized before final code generation
Learn More →
Q. Which of the following statements is true about LL and LR parsers?
-
A.
LL parsers are more powerful than LR parsers.
-
B.
LR parsers can handle all LL grammars.
-
C.
LL parsers can handle all LR grammars.
-
D.
Both LL and LR parsers are equivalent in power.
Solution
LR parsers can handle all LL grammars, but not all LR grammars can be parsed by LL parsers.
Correct Answer:
B
— LR parsers can handle all LL grammars.
Learn More →
Q. Which of the following tools is commonly used to implement a lexical analyzer?
-
A.
Yacc
-
B.
Lex
-
C.
Bison
-
D.
ANTLR
Solution
Lex is a tool specifically designed for generating lexical analyzers.
Correct Answer:
B
— Lex
Learn More →
Q. Which optimization technique can help reduce the number of memory accesses?
-
A.
Loop fusion
-
B.
Function inlining
-
C.
Dead code elimination
-
D.
Code hoisting
Solution
Loop fusion can help reduce the number of memory accesses by combining multiple loops that iterate over the same data.
Correct Answer:
A
— Loop fusion
Learn More →
Q. Which optimization technique can lead to a trade-off between speed and memory usage?
-
A.
Function inlining
-
B.
Loop fusion
-
C.
Code hoisting
-
D.
Strength reduction
Solution
Function inlining can lead to a trade-off between speed and memory usage, as it increases code size but can reduce function call overhead.
Correct Answer:
A
— Function inlining
Learn More →
Q. Which optimization technique focuses on reducing the number of instructions executed?
-
A.
Loop unrolling
-
B.
Constant folding
-
C.
Common subexpression elimination
-
D.
Code motion
Solution
Constant folding focuses on reducing the number of instructions executed by evaluating constant expressions at compile time.
Correct Answer:
B
— Constant folding
Learn More →
Q. Which optimization technique involves removing code that does not affect the program's output?
-
A.
Loop unrolling
-
B.
Dead code elimination
-
C.
Constant folding
-
D.
Inlining
Solution
Dead code elimination is the optimization technique that removes code that does not affect the program's output.
Correct Answer:
B
— Dead code elimination
Learn More →
Q. Which parsing technique is generally more powerful, LL or LR?
-
A.
LL
-
B.
LR
-
C.
Both are equally powerful.
-
D.
Neither is powerful.
Solution
LR parsing is generally more powerful than LL parsing as it can handle a larger class of grammars.
Correct Answer:
B
— LR
Learn More →
Showing 91 to 98 of 98 (4 Pages)