All mock tests are FREE till 31 December — register to save your progress
UGC NET · PAPER 2

UGC NET Paper 2 Computer Science – Unit 8: Theory of Computation and Compilers PYQ (December 2024)

12 questions · answer key at the end · updated 11 Oct 2026
Q19. Which of the following is TRUE about the Pumping Lemma for regular languages?
  1. It is a property used to prove that languages are not regular
  2. It applies only to infinite regular languages
  3. It applies to all context-free languages
  4. It applies to all recursively enumerable languages
Answer & explanation →
Q31. Regarding code optimization (peephole optimization), choose the correct sequence
A. Algebraic Simplification
B. Use of machine idioms
C. Redundant-instruction elimination
D. Flow of control optimization
E. Improved target code
Choose the correct answer from the options given below:
  1. A, C, B, D, E
  2. B, C, D, A, E
  3. C, D, A, B, E
  4. D, B, A, C, E
Answer & explanation →
Q37. Which of the following represents the language accepted by the Turing machine with the transition function (δ):
δ(q0, a) = (q1, x, R)
δ(q1, a) = (q1, a, R)
δ(q1, y) = (q1, y, R)
δ(q1, b) = (q2, y, L)
δ(q2, y) = (q2, y, L)
δ(q2, a) = (q2, a, L)
δ(q2, x) = (q0, x, R)
δ(q0, y) = (q3, y, R)
δ(q3, y) = (q3, y, R)
δ(q3, □) = (qf, □, R)
  1. L = {aⁿbⁿ | n ≥ 0}
  2. L = {aⁿbⁿ | n ≥ 1}
  3. L = {aⁿbⁿ | n > 0}
  4. L = {aⁿbⁿ | n > 1}
Answer & explanation →
Q43. Match List I with List II
List IList II
A. Conflict ResolutionI. Three-Address Code
B. Common SubexpressionII. Precedence
C. QuadruplesIII. Syntax Directed Translations
D. L-Attributed definitionsIV. Directed Acyclic Graph (DAG)
  1. A-III, B-II, C-IV, D-I
  2. A-II, B-IV, C-I, D-III
  3. A-II, B-III, C-I, D-IV
  4. A-IV, B-I, C-II, D-III
Answer & explanation →
Q56. Match List I with List II
List IList II
A. Type-0 GrammarI. Linear Grammar
B. Type-1 GrammarII. GNF
C. Type-2 GrammarIII. x → y, |x| ≤ |y|; x, y ∈ (V ∪ T)*
D. Type-3 GrammarIV. Recursively Enumerable
  1. A-I, B-II, C-III, D-IV
  2. A-II, B-I, C-III, D-IV
  3. A-III, B-II, C-IV, D-I
  4. A-IV, B-III, C-I, D-II
Answer & explanation →
Q66. Which of the following CFG(s) is/are in Chomsky Normal Form? (All capital letters are variables & lower case letters are terminals)
A. S → ABC | AB, A → a, B → b, C → d
B. X → RT | TR, T → t, R → XT | r
C. P → qP | sQ, Q → r | s
D. M → MN | MP, N → nm | n, P → p
Choose the correct answer from the options given below:
  1. A & B only
  2. B only
  3. C only
  4. B & D only
Answer & explanation →
Q74. yacc is which of the following parsers?
  1. Predictive Parser
  2. SLR Parser
  3. CLR Parser
  4. LALR Parser
Answer & explanation →

Directions (Q91–95): A machine is represented by states Q, input alphabet Σ, transition function δ, initial state q0 and final states F. The machine accepts all strings over Σ = {a, b} which start and end with any combination of the alphabet symbols, and in which abb occurs as a substring (i.e. the language of all strings over {a, b} containing abb).

Q91. For the above-mentioned passage, which of the following automata is correct? Each option is described by its transitions (start state 1).
  1. States 1–4, final {4}: 1 –a,b→ 1, 1 –a→ 2, 2 –b→ 3, 3 –b→ 4
  2. States 1–4, final {4}: 1 –a→ 2, 2 –b→ 3, 3 –b→ 4, 4 –a,b→ 4
  3. States 1–4, final {4}: 1 –a,b→ 1, 1 –a→ 2, 2 –b→ 3, 3 –b→ 4, 4 –a,b→ 4
  4. States 1–3, start and final {1}: 1 –a,b→ 1, 1 –a→ 2, 2 –b→ 3, 3 –b→ 1
Answer & explanation →
Q92. For the above specified passage, which of the following represents the grammar for the language accepted by the machine?
  1. S → AabbB, A → aA | ε, B → bB | ε
  2. S → abbA, A → aA | ε | bA
  3. S → AabbA, A → aA | bA | ε
  4. S → Aabb, A → aA | bA | ε
Answer & explanation →
Q93. Which of the following represents the minimum-state DFA for the above specified passage?
  1. States 1–5, final {4, 5}: 1 –a→ 1, 1 –a→ 2, 2 –a→ 2, 2 –a→ 3, 3 –b→ 2, 3 –b→ 4, 4 –a→ 4, 4 –b→ 5, 5 –a→ 4
  2. States 1–4, final {4}: 1 –b→ 1, 1 –a→ 2, 2 –a→ 2, 2 –a→ 3, 3 –b→ 2, 3 –b→ 4, 4 –a,b→ 4
  3. States 1–6, final {4, 5, 6}: 1 –a→ 2, 2 –a→ 2, 2 –b→ 3, 3 –a→ 2, 3 –b→ 4, 4 –b→ 4, 4 –a→ 5, 5 –b→ 6, 6 –a→ 6, 6 –a→ 5
  4. All are NFA
Answer & explanation →
Q94. For the above specified passage, which of the following is a DFA for the language accepted by the machine?
  1. States 1–4, final {4}: 1 –a,b→ 1, 1 –a→ 2, 2 –b→ 3, 3 –b→ 4, 4 –a,b→ 4
  2. States 1–4, final {4}: 1 –b→ 1, 1 –a→ 2, 2 –a→ 2, 2 –b→ 3, 3 –b→ 4, 4 –a,b→ 4
  3. States 1–6, final {4, 5, 6}: 1 –b→ 1, 1 –a→ 2, 2 –a→ 2, 2 –b→ 3, 3 –a→ 2, 3 –b→ 4, 4 –b→ 4, 4 –a→ 5, 5 –a→ 5, 5 –b→ 6, 6 –a→ 5, 6 –b→ 4
  4. States 1–6, final {4, 5, 6}: 1 –a→ 1, 1 –b→ 2, 2 –a→ 2, 2 –b→ 3, 3 –a→ 2, 3 –b→ 4, 4 –a→ 4, 4 –b→ 5, 5 –b→ 5, 5 –a→ 6, 6 –b→ 5
Answer & explanation →
Q95. For the above specified passage, which of the following represents the regular expression?
  1. (a + b)* aab
  2. aba (a + b)*
  3. b (a + b)* b (a + b)* a (a + b)*
  4. (a + b)* abb (a + b)*
Answer & explanation →

Answer key

  1. 19 – A
  2. 31 – C
  3. 37 – B
  4. 43 – B
  5. 56 – D
  6. 66 – B
  7. 74 – D
  8. 91 – C
  9. 92 – C
  10. 93 – D
  11. 94 – C
  12. 95 – D