πŸ“Š Theory of Computation and Compiler Design
Q. From the given data below : a b b a a b b a a b which one of the following is not a word in the dictionary created by LZ-coding (the initial words are a, b)?
  • (A) a b
  • (B) b b
  • (C) b a
  • (D) b a a b
πŸ’¬ Discuss
βœ… Correct Answer: (D) b a a b
πŸ“Š Theory of Computation and Compiler Design
Q. In compiler optimization, operator strength reduction uses mathematical identities to replace slow math operations with faster operations. Which of the following code replacements is an illustration of operator strength reduction?
  • (A) Replace P + P by 2 * P or Replace 3 + 4 by 7.
  • (B) Replace P * 32 by P < < 5
  • (C) Replace P * 0 by 0
  • (D) Replace (P < <4) – P by P * 15
πŸ’¬ Discuss
βœ… Correct Answer: (B) Replace P * 32 by P < < 5
πŸ“Š Theory of Computation and Compiler Design
Q. Debugger is a program that
  • (A) allows to examine and modify the contents of registers
  • (B) does not allow execution of a segment of program
  • (C) allows to set breakpoints, execute a segment of program and display contents of register
  • (D) All of the above
πŸ’¬ Discuss
βœ… Correct Answer: (C) allows to set breakpoints, execute a segment of program and display contents of register
πŸ“Š Theory of Computation and Compiler Design
Q. Consider the following two sets of LR(1) items of an LR(1) grammar.
X -> c.X, c/d
X -> .cX, c/d
X -> .d, c/d
X -> c.X, $
X -> .cX, $
X -> .d, $
Which of the following statements related to merging of the two sets in the
corresponding LALR parser is/are FALSE?
1. Cannot be merged since look aheads are different.
2. Can be merged but will result in S-R conflict.
3. Can be merged but will result in R-R conflict.
4. Cannot be merged since goto on c will lead to two different sets.
  • (A) 1 only
  • (B) 2 only
  • (C) 1 and 4 only
  • (D) 1, 2, 3, and 4
πŸ’¬ Discuss
βœ… Correct Answer: (D) 1, 2, 3, and 4
πŸ“Š Theory of Computation and Compiler Design
Q. Which of the following statements are TRUE?
I. There exist parsing algorithms for some programming languages whose complexities are less than O(n3).
II. A programming language which allows recursion can be implemented with static storage allocation.
III. No L-attributed definition can be evaluated in the framework of bottom-up parsing.
IV. Code improving transformations can be performed at both source language and intermediate code level.
  • (A) I and II
  • (B) I and IV
  • (C) III and IV
  • (D) I, III and IV
πŸ’¬ Discuss
βœ… Correct Answer: (B) I and IV
πŸ“Š Theory of Computation and Compiler Design
Q. Which of the following describes a handle (as applicable to LR-parsing) appropriately?
  • (A) It is the position in a sentential form where the next shift or reduce operation will occur
  • (B) It is non-terminal whose production will be used for reduction in the next step
  • (C) It is a production that may be used for reduction in a future step along with a position in the sentential form where the next shift or reduce operation will occur
  • (D) It is the production p that will be used for reduction in the next step along with a position in the sentential form where the right hand side of the production may be found
πŸ’¬ Discuss
βœ… Correct Answer: (D) It is the production p that will be used for reduction in the next step along with a position in the sentential form where the right hand side of the production may be found
πŸ“Š Theory of Computation and Compiler Design
Q. An LALR(1) parser for a grammar G 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
πŸ’¬ Discuss
βœ… Correct Answer: (B) the LR(1) parser for G has S-R conflicts
πŸ“Š Theory of Computation and Compiler Design
Q. Consider the following two statements:
P: Every regular grammar is LL(1)
Q: Every regular set has a LR(1) grammar
Which of the following is TRUE?
  • (A) Both P and Q are true
  • (B) P is true and Q is false
  • (C) P is false and Q is true
  • (D) Both P and Q are false
πŸ’¬ Discuss
βœ… Correct Answer: (C) P is false and Q is true

Jump to