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. Which of the following Grammars is/are only Context Free?
    Answer: B. C, D Only Paper 2 CS · June 2025
  2. Consider the following DFA Which of the following NFA is valid for the given DFA ?
    Answer: D. Paper 2 CS · June 2025
  3. Consider the following DFA that generates set of Σ = {a, b, c} strings over Now identify that which of the followings is the best description of the language for the above DFA
    Answer: D. L = { strings having an even count (including 0) of the substring 'abc' } Paper 2 CS · June 2025
  4. Match List I with List II. List I: A. Type 3 Grammar, B. Type 2 Grammar, C. Type 1 Grammar, D. Type 0 Grammar. List II: I. V → (V ∪ Σ)*; II. λVβ → λ(V ∪ Σ)*β, where λ, β ∈ (V ∪ Σ)*; III. (V ∪ Σ)* → (V ∪ Σ)*; IV. V → VΣ…
    Answer: C. A → IV, B → I, C → II, D → III Paper 2 CS · June 2025
  5. Arrange the following parsers in increasing order of their power of handling grammars i.e. from the least powerful parser to the most powerful parser. A. LR (0) B. LR (1) C. LALR(1) D. LL (0) E. SLR
    Answer: C. LL(0) → LR(0) → SLR → LALR(1) → LR(1) Paper 2 CS · June 2025
  6. Which of the following is the Optimized version for the given TAC in the passage
    Answer: C. 100: t1 = y + 2 101: limit = 10 102: num = 9 103: b = t1 104: if i > j goto 106… Paper 2 CS · June 2025
  7. What all blocks does Block 3 and Block 5 dominate in the Flow graph for the TAC given in the passage?
    Answer: A. Block 3:3 ; Block 5:5 Paper 2 CS · June 2025
  8. Which of the followings is the correct Flow graph for the TAC given in the passage?
    Answer: A. Paper 2 CS · June 2025
  9. Match the LIST-I with LIST-II
    Answer: B. A-II, B-IV, C-I, D-III Paper 2 CS · December 2024
  10. Match List I with List II. List I: A. Type-0 grammar, B. Type-1 grammar, C. Type-2 grammar, D. Type-3 grammar. List II: I. Linear grammar; II. GNF; III. x → y, |x| ≤ |y|, x, y ∈ (V ∪ T)*; IV. Recursively enumerable.
    Answer: D. A-IV, B-III, C-I, D-II Paper 2 CS · December 2024
  11. For the above mentioned passage which of the following is correct?
    Answer: C. Paper 2 CS · December 2024
  12. Which of the following represented the minimum state DFA for the above specified passage?
    Answer: B. Paper 2 CS · December 2024
  13. For the above specified passage, which of the following is DFA for the language represented/accepeted by machine?
    Answer: C. Paper 2 CS · December 2024
  14. For the above specified passage, which of the following represents the regular expression?
    Answer: D. (a + b)* abb (a + b)* Paper 2 CS · December 2024
  15. Consider the Grammar: T → Qx Q → RS R → y ∣ ϵ S → z ∣ ϵ Here x, y, z are terminals and T, Q, R, S are non- terminals. What will be the follow set of the non-terminal R?
    Answer: C. {z,x} Paper 2 CS · June 2024 (Re-Exam)
  16. Which of the following tasks could be attained using syntax trees in compiler design ? (A) Type Checking (B) Code Generation (C) Code Optimization (D) Error Handling
    Answer: A. (A), (B), (C) Only Paper 2 CS · June 2024 (Re-Exam)
  17. Arrange the following stages of parsing in the correct order as they typically occur in the compilation process. (A) Lexical Analysis (B) Sematic Analysis (C) Syntax Analysis (D) Intermediate Code Generation (E) Code Op…
    Answer: B. (A), (C), (B), (D), (E) Paper 2 CS · June 2024 (Re-Exam)
  18. Arrange the following Language Classes in ascending order according to their expressive power, as defined by Chomsky hierarchy: (A) Context-free languages (B) Context-sensitive languages (C) Regular languages (D) Unrest…
    Answer: A. (C), (A), (B), (D) Paper 2 CS · June 2024 (Re-Exam)
  19. Which of the following is a context-free language? (A) {wⁱ xʲ yᵏ zˡ | i + k = j + l, i, j, k, l ≥ 0} (B) {wⁱ xʲ yᵏ zˡ | i = j, k = l} (C) {wⁱ xʲ yᵏ zˡ | i = j = k and k ≠ l} (D) {wⁱ xʲ yᵏ zˡ | i = j = k + l} (E) {wⁱ xʲ…
    Answer: A. (A) and (B) Only Paper 2 CS · June 2024 (Re-Exam)
  20. Match List I with List II. List I: A. A → aB | a (a ∈ T; A, B ∈ V), B. A → BC | a (a ∈ T; A, B, C ∈ V), C. LL(1) grammar, D. Halting problem. List II: I. Recursive descent parser, II. Turing machine, III. Chomsky Normal…
    Answer: A. A-IV, B-III, C-I, D-II Paper 2 CS · June 2024 (Cancelled)
  21. For the regular languages and context-free languages which is not correct? A. both are closed under union operation B. both are closed under concatenation operation C. both are closed under intersection operation D. bot…
    Answer: C. C and D Only Paper 2 CS · June 2024 (Cancelled)
  22. Match List-I with List-II :
    Answer: D. A-III, B-I, C-IV, D-Il Paper 2 CS · June 2024 (Cancelled)
  23. For the given two machines which of the following is correct?
    Answer: C. both are equivalent Machines Paper 2 CS · June 2024 (Cancelled)
  24. Let L= {ab, aa, baa}. Which of the following strings are not in L*?
    Answer: C. baaaaabaaaab Paper 2 CS · December 2023
  25. Let A={a, b} and L=A*. Let X={anbn, n>0}. The languages L U X and X are respectively :
    Answer: C. Regular, Not regular Paper 2 CS · December 2023
  26. Which of the following symbol table implementations is best suited if access time is to be minimum?
    Answer: C. Hash Table Paper 2 CS · December 2023
  27. The sum of minimum and maximum number of final states for a Deterministic Finite Automata (DFA) having ' P ' state is equal to :
    Answer: C. P+1 Paper 2 CS · December 2023
  28. Three address codes can be represented in special structures known as : (A) Quadruples (B) Triples (C) Patterns (D) Indirect Triples
    Answer: B. (A), (B) and (D) Only Paper 2 CS · December 2023
  29. Which of the statement is/are CORRECT ? (A) Moore and Mealy machines are finite state machines with output capabilities. (B) Any given Moore machine has an equivalent Mealy machine. (C) Any given Mealy machine has an eq…
    Answer: B. (A), (B) and (C) Only Paper 2 CS · December 2023
  30. Match List - I with List - II according to input to the compiler phase that process it :
    Answer: B. (a)-(II), (b)-(I), (c)-(IV), (d)-(III) Paper 2 CS · December 2023