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.

Topic-wise mock tests

  1. Arrange the following phases of a compiler as per their order of execution (start to end) (a) Target code generation (b) Syntax Analysis (c) Code optimization (d) Semantic Analysis (e) Lexical Analysis
    Answer: C. (e), (b), (d), (c), (a) Paper 2 CS · December 2023
  2. Consider the following finite automata F1 that accepts a language L Let F2 be a finite automata which is obtained by reversal of F1. Then which of the following is correct?
    Answer: B. L(F1) = L(F2) Paper 2 CS · June 2023
  3. Which phase of compiler checks the grammar of programming?
    Answer: D. Syntax analysis Paper 2 CS · June 2023
  4. A. The set of turning machine codes for TM's that accept all inputs that are palindromes (possible along with some other inputs) is decidable B. The language of codes for TM's M that when started with blank tape, eventu…
    Answer: D. B and D only G = R H = {−1, 1} Paper 2 CS · June 2023
  5. Which of the following parser is most powerful parser?
    Answer: C. Canonical LR Paper 2 CS · June 2023
  6. Which of the following statement is correct?
    Answer: C. L = {aⁿbʲ : n = j²} is not a context-free language. Paper 2 CS · June 2023
  7. The compiler for high level language that runs on one machine and produces code for other machine is called-
    Answer: A. Cross compiler Paper 2 CS · June 2023
  8. In the context of Binding which one of the following is incorrect?
    Answer: C. Internal functions are known at link time Paper 2 CS · December 2022 (Shift 1)
  9. In Pumping Lemma for context-free languages, to say a language is satisfying pumping lemma, vx what is the minimum length of ' ' together, if you consider the string as 'uvwxy'?
    Answer: B. 1 n Paper 2 CS · December 2022 (Shift 1)
  10. Which of the following is -free grammar?
    Answer: B. Type-1 Paper 2 CS · December 2022 (Shift 1)
  11. While processing a string by an LR parser, the reading of the given string by the parser is-
    Answer: B. From left to right Paper 2 CS · December 2022 (Shift 1)
  12. What is the minimum and maximum number of initial, dead, unreachable and final states in a n valid ' ' state finite automaton, where the φ language accepted is not ' '?
    Answer: D. Minimum 1, 0, 0, 1; Maximum 1, n − 1, n − 1, n Paper 2 CS · December 2022 (Shift 1)
  13. Which of the following finite automata recognize L = {a, b}*? (Transition tables A–D are shown; in each, the start state q0 is accepting.)
    Answer: D. A, B, C and D Paper 2 CS · December 2022 (Shift 1)
  14. Match List I with List II
    Answer: B. A-III, B-II, C-I, D-IV Paper 2 CS · December 2022 (Shift 1)
  15. Consider the following statements: (A) For every regular language, we can design Turing Machine (B) For every context free language, we can design Turing Machine Which of the following is correct?
    Answer: D. Statement-A and Statement-B both are true. Paper 2 CS · December 2022 (Shift 1)
  16. The transition function ' ' in multi-tape Turing machine is defined as:
    Answer: C. δ : Q × Γᵏ → Q × Γᵏ × {L, R, S}ᵏ Paper 2 CS · December 2022 (Shift 2)
  17. In Pumping Lemma for regular languages, to say a language is satistying pumping lemma, what is the mınımum length of ' y ' if you consider the string as ' x y z '?
    Answer: C. 1 Paper 2 CS · December 2022 (Shift 2)
  18. The item generated by the production is :
    Answer: A. A → . Paper 2 CS · December 2022 (Shift 2)
  19. In the ε-NFA M = ({q0, q1, q2, q3}, {a}, δ, q0, {q3}) with δ: q0 –ε→ q1, q1 –ε→ q2, q2 –a→ {q2, q3}, and no other moves, what is the minimum length of a string that reaches the final state?
    Answer: B. 1 Paper 2 CS · December 2022 (Shift 2)
  20. Which of the following is (are) correct? 1. The language for the given expression is L = {aⁿbⁿcᵐdᵐ | n ≥ 1, m ≥ 1} ∪ {aⁿbᵐcᵐdⁿ | n ≥ 1, m ≥ 1}. 2. A context-free grammar for it is S → AB | C, A → aAb | ab, B → cBd | cd,…
    Answer: C. Both 1 and 2 are correct Paper 2 CS · December 2022 (Shift 2)
  21. Which of the following are correct for regular expressions? a. ∅ + L = L + ∅ = L b. εL = Lε = L c. ∅L = L∅ = ∅ d. ∅L = L∅ = L
    Answer: B. a, b and c only Paper 2 CS · December 2022 (Shift 2)
  22. Match the following based on the language accepted by using brute force method of parsing.
    Answer: B. a-II, b-IV, c-I, d-III Paper 2 CS · December 2022 (Shift 2)
  23. What is the safest order while simplifying Context Free Grammar? ∈
    Answer: A. Elimination of -productions, Unit productions, and then Useless symbols & produ… Paper 2 CS · December 2022 (Shift 2)
  24. What is the Move in the cell with number 'M1' of the resultant Table?
    Answer: B. (q2,X2,L) Paper 2 CS · December 2022 (Shift 2)
  25. What is the Move in the cell with the number 'M2' of the resultant Table?
    Answer: D. Error entry Paper 2 CS · December 2022 (Shift 2)
  26. What is the Move in the cell with number 'M3' of the resultant Table?
    Answer: C. (q1,x1, R) Paper 2 CS · December 2022 (Shift 2)
  27. What is the Move in the cell with number 'M4' of the resultant Table?
    Answer: B. (q3, Y1, R) Paper 2 CS · December 2022 (Shift 2)
  28. What is the Move in the cell with number 'M5' of the resultant Table?
    Answer: A. (q4,X2, R) Paper 2 CS · December 2022 (Shift 2)
  29. The reduced grammar equivalent to S → AB | CA, B → BC | AB, A → a, C → aB | b is
    Answer: A. S → CA, A → a, C → b Paper 2 CS · September 2022
  30. Consider the grammar G: S → AbB, A → aAb | λ, B → bB | λ. Which language does G generate?
    Answer: A. {aⁿbᵐ : n ≥ 0, m > n} Paper 2 CS · September 2022