0% found this document useful (0 votes)
13 views10 pages

At&cd

The document contains a series of multiple-choice questions related to Automata Theory and Compiler Design, covering topics such as loading schemes, parsing techniques, optimization methods, and memory characteristics. Each question is followed by the correct answer and point value. The content is structured to test knowledge on various aspects of compiler design and automata theory.

Uploaded by

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

At&cd

The document contains a series of multiple-choice questions related to Automata Theory and Compiler Design, covering topics such as loading schemes, parsing techniques, optimization methods, and memory characteristics. Each question is followed by the correct answer and point value. The content is structured to test knowledge on various aspects of compiler design and automata theory.

Uploaded by

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

Automata Theory & Compiler Design

MULTIPLE CHOICE

1. In an absolute loading scheme which loader function is accomplished by assembler?


a) Re-allocation c) Linking
b) Allocation d) Loading
ANS: A PTS: 1

2. Relocating bits used by relocating loader are specified by __________


a) Relocating loader itself
b) Linker
c) Assembler
d) Macro Processor
ANS: B PTS: 1

3. Running time of a program depends on __________


a) Addressing mode b) Order of c) The usage of d) All of the
computations machine idioms mentioned
ANS: D PTS: 1

4. Computers use addressing mode techniques for ____________


a) Giving programming versatility to the user by providing facilities as pointers to
memory counters for loop control
b) To reduce number of bits in the field of instruction
c) Specifying rules for modifying or interpreting address field of the instruction
d) All of the mentioned
ANS: D PTS: 1

5. What characteristic of RAM memory makes it not suitable for permanent storage?
a) Too slow b) Unreliable c) It is volatile d) Too bulky
ANS: C PTS: 1

6. A bottom up parser generates __________


a) Right most derivation
b) Rightmost derivation in reverse
c) Leftmost derivation
d) Leftmost derivation in reverse
ANS: B PTS: 1

7. An optimizer Compiler __________


a) Is optimized to b) Is optimized to c) Optimize the code d) None of the
occupy less space occupy less space mentioned
& Optimize the
code
ANS: C PTS: 1
8. 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
ANS: C PTS: 1

9. In Reverse Polish notation, expression A*B+C*D is written as __________


a) AB*CD*+ b) A*BCD*+ c) AB*CD+* d) A*B*CD+
ANS: A PTS: 1

10. The optimization which avoids test at every iteration is?


a) Loop unrolling b) Loop jamming c) Constant folding d) None of the
mentioned
ANS: A PTS: 1

11. Assembly language ________


a) Uses alphabetic codes in place of binary numbers used in machine language
b) Is the easiest language to write programs
c) Need not be translated into machine language
d) None of the mentioned
ANS: A PTS: 1

12. A group of bits that tell the computer to perform a specific operation is known as ________
a) Instruction code b) Micro-operation c) Accumulator d) Register
ANS: A PTS: 1

13. Shift reduce parsers are __________


a) Top down Parser b) Bottom Up parser c) May be top down d) None of the
or bottom up mentioned
ANS: B PTS: 1

14. S -> CC
C -> cC | d
The grammar is
a) LL(1) c) LALR(1) but not SLR(1)
b) SLR(1) but not LL(1) d) LR(1) but not LALR(1)

ANS: A PTS: 1

15. Translation from symbolic program into Binary is done in __________


a) Two passes b) Directly c) Three passes d) Four passes
ANS: A PTS: 1

16. Match the following:


List-I List-II

A. Lexical analysis 1. Graph coloring

B. Parsing 2. DFA minimization

C. Register allocation 3. Post-order traversal

D. Expression evaluation 4. Production tree

ABCD
a) 2 3 1 4 c) 2 4 1 3
b) 2 1 4 3 d) 2 3 4 1
ANS: C PTS: 1

17. ‘Aging registers’ are _______


a) Counters which indicate how long ago their associated pages have been
Referenced
b) Registers which keep track of when the program was last accessed
c) Counters to keep track of last accessed instruction
d) Counters to keep track of the latest data structures referred
ANS: A PTS: 1

18. Which of the following pairs is the most powerful?


a) SLR, LALR c) SLR canonical LR
b) Canonical LR ,LALR d) LALR canonical LR
ANS: B PTS: 1

19. Consider the following grammar G.


S -> F | H
F -> p | c
H -> d | c
Which one is true?
S1: All strings generated by G can be parsed with help of LL (1).
S2: All strings generated by G can be parsed with help of LR (1).
a) Only S1 c) both S1 S2
b) Only S2 d) None
ANS: D PTS: 1

20. What is the maximum number of reduce moves that can be taken by a bottom-up parser for a
grammar with no epsilon- and unit-production to parse a string with n tokens?
a) n/2 b) n-1 c) 2n-1 d) 2^n
ANS: B PTS: 1

21. What is the similarity between LR, LALR and SLR?


a) Use same algorithm, but different parsing c) Their Parsing tables and algorithm are
table similar but uses top down approach
b) Same parsing table, but different d) Both Parsing tables and algorithm are
algorithm different
ANS: A PTS: 1

22. An LR-parser can detect a syntactic error as soon as __________


a) The parsing starts b) It is possible to do c) It is possible to do d) Parsing ends
so a left-to-right so a right-to-left
scan of the input scan of the input
ANS: B PTS: 1

23. Which of these is true about LR parsing?


a) Is most general b) It is still efficient c) Is most general d) None of the
non-backtracking non-backtracking mentioned
shift-reduce shift-reduce
parsing parsing & It is still
efficient
ANS: C PTS: 1

24. If a state does not know whether it will make a shift operation or reduction for a terminal is
called _________
a) Shift/reduce conflict c) Shift conflict
b) Reduce /shift conflict d) Reduce conflict
ANS: A PTS: 1

25. 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 c) Closure and additive operations work a
bit different little bit different
b) Closure and goto operations work d) Closure and associatively operations work
similarly a little bit different
ANS: A PTS: 1

26. Consider the following C code segment.


for for if i # i } } }

Which one to the following false?


a) The code contains loop-in variant computation
b) There is scope of common sub-expression elimination in this code
c) There is scope strength reduction in this code
d) There is scope of dead code elimination in this code
ANS: D PTS: 1

27. In the correct grammar above, what is the length of the derivation (number of steps starting
from S to generate the string a l b m with l ! m?
a) max (l, m) + 2 b) l+m+2 c) l + m + 3 d) max (l, m) + 3
ANS: A PTS: 1

28. Some code optimizations are carried out on the intermediate code because _______________
a) They enhance the portability of the complier to other target processors
b) Program analysis is name accurate on intermediate code than on machine code
c) The information from data flow analysis cannot otherwise be used for optimization
d) The information from the front end cannot otherwise be used for optimization
ANS: B PTS: 1

29. Which one of the following is a top-down parser?


a) Recursive descent parser c) An LR(k) parser
b) Operator precedence parser d) An LALR(k) parser
ANS: A PTS: 1

30. An LALR(1) parser for a grammar can have shift-reduce (S-R) conflicts if and only if
___________
a) The SLR(1) parser for G has S-R conflicts
b) The LR(1) parser for G has S-R conflicts
c) The LR(0) parser for G has S-R conflicts
d) The LALR(1) parser for G has reduce-reduce conflicts
ANS: B PTS: 1

31. Which of the following techniques is used to replace run-time computations by compile time
computations?
a) constant folding b) code hoisting c) peephole d) invariant
optimization computation
ANS: D PTS: 1

32. What data structure in a complier is used for managing information about variables and their
attributes?
a) Abstract syntax tree c) Semantic stack
b) Symbol table d) Parse table
ANS: B PTS: 1

33. The lexical analyzer takes _________ as input and produces a stream of _______ as output.
a) Source program, tokens c) Either A and B
b) Token, source program d) None of the mentioned
ANS: A PTS: 1

34. The action of parsing the source program into proper syntactic classes is called ________
a) Syntax analysis c) Interpretation analysis
b) Lexical analysis d) General syntax analysis
ANS: B PTS: 1

35. What is the task of the lexical analysis?


a) None of the mentioned
b) To build a literal and identifier table
c) To build a uniform symbol table
d) To build a uniform symbol table, literal and identifier table
ANS: D PTS: 1
36. Which of the following class of statement usually produces no executable code when compiled?
a) Assignment statement c) Input and output statements
b) Structural statements d) Declaration
ANS: B PTS: 1

37. Code optimization is responsibility of--------


a) Application b) System c) Operating system d) all
programmer programmer
ANS: B PTS: 1

38. Dead-code elimination in machine code optimization refersto -----------


a) Removal of all labels. c) Removal of function which are not
involved.
b) Removal of values that never get used. d) Removal of a module after its use.
ANS: B PTS: 1

39. Which of the following statement is false?


a) Flow graph is used to represent DAG. c) The first statement of three address code is
always leader of the first basic block.
b) Three address code is the input to the code d) Transformation of block is needed for
generator. code optimization.
ANS: A PTS: 1

40. Substitution of values for names (whose values are constants) is done in----------
a) Local optimization c) Constant folding
b) Loop optimization d) Strength reduction
ANS: C PTS: 1

41. Quadruple is a record structure with four fields-------


a) Op, arg1, arg2 and b) op1, op2, arg2 and c) arg1, arg2, result d) all
result result and op
ANS: A PTS: 1

42. Which parser is most powerful in the following parsers?


a) Operator b) SLR c) CLR d) LALR
Precedence
ANS: C PTS: 1

43. A Stack-organised Computer uses instruction of __________


a) Indirect addressing c) Zero addressing
b) Two-addressing d) Index addressing
ANS: C PTS: 1

44. Which part of the compiler highly used the grammar concept?
a) Code optimization c) Parser
b) Code generation d) Scanner
ANS: C PTS: 1
45. Leaf nodes in a parse tree indicate?
a) sub-terminals b) half-terminals c) non-terminals d) terminals
ANS: D PTS: 1

46. Which graph describes the basic block and successor relationship?
a) Control graph c) DAG
b) Flow graph d) Hamilton graph
ANS: B PTS: 1

47. In how many types of optimization can be divided?


a) 2 c) 4
b) 3 d) 5
ANS: A PTS: 1

48. The value of which variable is updated inside the loop by a loop-invariant value?
a) loop c) induction
b) strength d) invariable
ANS: C PTS: 1

49. Which compiler runs on one machine and generates code for multiple machines?
a) Multipass b) Optimizing c) Cross compiler d) Onepass compiler
compiler compiler
ANS: C PTS: 1

50. Which method merges the multiple loops into the single one?
a) Loop fusion or b) Constant Folding c) Loop rolling d) None of the above
jamming
ANS: A PTS: 1

51. What type of conflicts can occur in the shift-reduce parsing?


a) reduce/reduce b) shift/reduce c) Both shift/reduce d) None
and reduce/reduce
ANS: C PTS: 1

52. Which algorithm invokes a function GETREG()?


a) Code motion b) Code optimization c) Intermediate Code d) Code generation
algorithm algorithm algorithm
ANS: D PTS: 1

53. The execution time of the code depends on?


a) the usage of machine idioms c) the orders in which the computations are
performed
b) the way the registers are used d) All of the mentioned
ANS: D PTS: 1

54. _________ register keeps track of the instructions stored in program stored in memory.
a) AR (Address Register) c) PC (Program Counter)
b) XR (Index Register) d) AC (Accumulator)
ANS: C PTS: 1

55. Which optimization technique is used to reduce the multiple jumps?


a) Latter optimization technique
b) Peephole optimization technique
c) Local optimization technique
d) Code optimization technique
ANS: B PTS: 1

56. Which of the following term is used to keep track of the location where the current values of the name
are stored?
a) Register descriptor c) Allocation descriptor
b) Address descriptor d) Flag register
ANS: B PTS: 1

57. Which of the following is not a type of assembler?


a) One pass b) Two pass c) Three pass d) Load and go
ANS: C PTS: 1

58. Which of the following structure has four fields?


a) Parse tree c) Triples
b) Quadruples d) Indirect Triples
ANS: B PTS: 1

59. One of the purposes of using intermediate code in compilers is to


a) Make parsing and semantic analysis simpler.
b) Improve error recovery and error reporting.
c) Increase the chances of reusing the machine-independent code optimizer in other
compilers.
d) Improve the register allocation.

ANS: C PTS: 1

60. Which statement is an abstract form of intermediate code?


a) 3- address c) address
b) 2- address d) Intermediate code
ANS: A PTS: 1

61. Substitution of values for names (whose values are constants) is done in
a) Local optimization c) Constant folding
b) Loop optimization d) Strength reduction
ANS: C PTS: 1

62. In compiler terminology reduction in strength means


a) Replacing run time computation by compile time computation
b) Removing loop invariant computation
c) Removing common sub expressions
d) Replacing a costly operation by a relatively cheaper one

ANS: D PTS: 1

63. Which of the following statements about peephole optimization is False?


a) It is applied to a small part of the code
b) It can be used to optimize intermediate code
c) To get the best out of this, it has to be applied repeatedly
d) It can be applied to the portion of the code that is not contiguous

ANS: D PTS: 1

64. The graph that shows basic blocks and their successor relationship is called:
a) DAG b) Control graph c) Flow graph d) Hamiltonian
graph

ANS: C PTS: 1

65. Identify the technique used to replace run-time computations with compile-time computations.
a) Code Hosting c) Invariant Computation
b) Peephole Optimization d) Constant Folding
ANS: D PTS: 1

66. The input of the code generator is


a) parse tree c) flow graph
b) intermediate code d) algorithm
ANS: B PTS: 1

67. Code optimization & generation phases are often referred as .


a) design phase c) optimization phase
b) back end d) front end
ANS: C PTS: 1

68. __________ selection involves what values to keep in which register.


a) Address c) Register
b) Value d) Instruction
ANS: C PTS: 1
69. Postfix notations are __________ representations.
a) linear c) virtual
b) graphical d) three-address
ANS: A PTS: 1

70. __________ are the fastest computational unit of a target machine.


a) Compiler c) Register
b) Analyzer d) Generator
ANS: C PTS: 1

71. Any instruction that follows conditional and unconditional jumps is _________
a) leader c) header
b) jump d) first
ANS: A PTS: 1

72. Local optimization enables improvement in ________ of code


a) efficiency c) execution time
b) running time d) compile time
ANS: C PTS: 1

73. DAG representation helps to eliminate _________


a) data redundancy c) redundant code
b) interrupts d) dead code
ANS: D PTS: 1

74. Code optimization & generation phases are often referred as _________
a) design phase c) optimization phase
b) back end d) front end
ANS: C PTS: 1

75. Elimination or replacement of unnecessary instruction in object code is called __________ .


a) code replacement c) code improvement
b) code elimination d) code optimization
ANS: B PTS: 1

You might also like