All mock tests are FREE till 31 December — register to save your progress
Paper 2 CS · UNIT 08

Theory of Computation and Compilers – Previous Year Questions

250 questions from past UGC NET Paper 2 – Computer Science papers, each with the correct answer. Open any question for its explanation.

  1. Which of the following parsers is the most powerful?
    Answer: C. Canonical LR Paper 2 CS · June 2023
  2. Which of the following statements is correct?
    Answer: C. L = {aⁿbʲ : n = j²} is not a context-free language. Paper 2 CS · June 2023
  3. A compiler for a high-level language that runs on one machine and produces code for another machine is called a
    Answer: A. Cross compiler Paper 2 CS · June 2023
  4. Shift-reduce conflicts are resolved by:
    Answer: D. Associativity and precedence Paper 2 CS · June 2024 (Cancelled Exam)
  5. Match List I with List IIList I List II A. A → aB | a (a ∈ T; A, B ∈ V) I. Recursive Descent Parser B. A → BC | a (a ∈ T; A, B, C ∈ V) II. Turing Machine C. LL(1) grammar III. Chomsky Normal Form D. Halting problem IV.…
    Answer: A. A-IV, B-III, C-I, D-II Paper 2 CS · June 2024 (Cancelled Exam)
  6. Which of the following is a function of the semantic analysis phase of compilation?
    Answer: A. Type conversion Paper 2 CS · June 2024 (Cancelled Exam)
  7. For regular languages and context-free languages, which is NOT correct? A. Both are closed under union B. Both are closed under concatenation C. Both are closed under intersection D. Both are closed under complementatio…
    Answer: C. C and D Only Paper 2 CS · June 2024 (Cancelled Exam)
  8. Match List I with List IIList I List II A. Back Tracking I. Automata B. Infinite languages with matching numbers II. Undecidable Problem C. Canonical LR Parser III. Predictive Parser D. Post Correspondence Problem IV. L…
    Answer: D. A-III, B-I, C-IV, D-II Paper 2 CS · June 2024 (Cancelled Exam)
  9. An ambiguous grammar is one which has: A. More than one derivation B. More than one leftmost derivation C. More than one rightmost derivation D. More than one parse tree E. More than one syntax tree Choose the correct a…
    Answer: C. D and E Only Paper 2 CS · June 2024 (Cancelled Exam)
  10. Arrange in appropriate order the construction of a finite automaton: A. Minimum-state DFA B. Regular expression C. NFA-ε D. Problem statement E. DFA Choose the correct answer from the options given below:
    Answer: B. D, B, C, E, A Paper 2 CS · June 2024 (Cancelled Exam)
  11. The grammar stmt → if expr then stmt else stmt | if expr then stmt suffers from:
    Answer: A. Ambiguity Paper 2 CS · June 2024 (Cancelled Exam)
  12. The language of the following PDA would be: δ(q0, a, z0) = (q0, aaaz0) δ(q0, a, a) = (q0, aaaa) δ(q0, b, a) = (q1, λ) δ(q1, b, a) = (q1, λ) δ(q1, ε, z0) = (qf, z0), where qf is the final state.
    Answer: C. {aⁿb³ⁿ | n > 0} Paper 2 CS · June 2024 (Cancelled Exam)
  13. For the given two machines over {a, b}, which of the following is correct? Machine 1: states A (start), B (final); A –a→ A, A –a→ B, B –b→ B, B –b→ A. Machine 2: states A (start), B (final), C (final); A –a→ B, B –a→ B,…
    Answer: C. Both are equivalent machines Paper 2 CS · June 2024 (Cancelled Exam)
  14. The number of tokens in the line ' for i in range (begin; end ; step) : ' is:
    Answer: D. 12 Paper 2 CS · June 2024 (Cancelled Exam)
  15. In the pumping lemma for context-free languages, for a string uvwxy, what is the minimum length of vx together?
    Answer: B. 1 Paper 2 CS · December 2022 Shift 1
  16. Which of the following is an ε-free grammar?
    Answer: B. Type-1 Paper 2 CS · December 2022 Shift 1
  17. While processing a string, an LR parser reads the input
    Answer: B. From left to right Paper 2 CS · December 2022 Shift 1
  18. What are the minimum and maximum numbers of initial, dead, unreachable and final states in a valid n-state finite automaton whose accepted language is not φ?
    Answer: D. Minimum: 1, 0, 0, 1; Maximum: 1, (n−1), (n−1), n Paper 2 CS · December 2022 Shift 1
  19. Which of the following finite automata recognise the language L = {a, b}*? A. M = ({q0}, {a, b}, δ, q0, {q0}) with δ(q0, a) = {q0}, δ(q0, b) = {q0} B. M = ({q0, q1}, {a, b}, δ, q0, {q0, q1}) with δ(q0, a) = δ(q0, b) = {…
    Answer: D. A, B, C and D Paper 2 CS · December 2022 Shift 1
  20. Which of the following statements are correct? A. Syntax-directed translation can be applied in type checking. B. Syntax-directed translation can be used in 3-address code generation. C. Syntax-directed translation can…
    Answer: A. A, B and C Paper 2 CS · December 2022 Shift 1
  21. Match List I with List II (stack and input configurations)List I List II A. Initial configuration of stack and input in LL parsing I. $ | w$ B. Final configuration of stack and input in LL parsing II. $ | $ C. Initial c…
    Answer: B. A-III, B-II, C-I, D-IV Paper 2 CS · December 2022 Shift 1
  22. The precedence of regular-expression operators from lowest to highest is:
    Answer: C. Union, Concatenation, Star Paper 2 CS · December 2022 Shift 1
  23. Consider the following statements: A. For every regular language, we can design a Turing machine. B. For every context-free language, we can design a Turing machine. Which of the following is correct?
    Answer: D. Statement A and Statement B are both true. Paper 2 CS · December 2022 Shift 1
  24. The transition function δ in a multi-tape Turing machine (k tapes) is defined as:
    Answer: C. δ : Q × Γk → Q × Γk × {L, R, S}k Paper 2 CS · December 2022 Shift 2
  25. In the pumping lemma for regular languages, writing the string as xyz, what is the minimum length of y?
    Answer: C. 1 Paper 2 CS · December 2022 Shift 2
  26. The item generated by the production A → ε is:
    Answer: A. A → . Paper 2 CS · December 2022 Shift 2
  27. In the ε-NFA M = ({q0, q1, q2, q3}, {a}, δ, q0, {q3}), where δ is given in the transition table below, what is the minimum length of string to reach the final state?State ε a q0 {q1} { } q1 {q2} { } q2 { } {q2, q3} q3 {…
    Answer: B. 1 Paper 2 CS · December 2022 Shift 2
  28. Which of the following is (are) correct about the regular expression a a* b b* c c* d d*? 1. The language for the given expression is L = {anbncmdm | n ≥ 1, m ≥ 1} ∪ {anbmcmdn | n ≥ 1, m ≥ 1} 2. The context-free grammar…
    Answer: C. Both 1 and 2 are correct Paper 2 CS · December 2022 Shift 2
  29. Which of the following statements are correct? 1. The first three-address instruction in the intermediate code is a leader. 2. The instruction exactly in the middle of the given three-address code is a leader. 3. Any in…
    Answer: C. 1, 3, 4 Paper 2 CS · December 2022 Shift 2
  30. Which of the following are correct for regular expressions? a. φ + L = L + φ = L b. εL = Lε = L c. φL = Lφ = φ d. φL = Lφ = L Choose the correct answer from the options given below:
    Answer: B. a, b and c only Paper 2 CS · December 2022 Shift 2