chapter
    Theory of Computation PYQs for GATE CS

    GATE CS Theory of Computation: 4 chapters, 47 previous year questions (100% of Theory of Computation), 0 practice questions and one solved question from each

    A question from this chapter

    Question 1
    2025 Slot Set2 PYQ
    Level 3: Exam Standard
    Let . For , let be the product of symbols in modulo 7. We take , where is the null string.

    For example, .

    Define .

    The number of states in a minimum state DFA for is ___________. (Answer in integer)
    Question 2
    2026 Slot Set2 PYQ
    Level 3: Exam Standard

    Which of the following grammars is/are ambiguous?

    Question 3
    2026 Slot Set2 PYQ
    Level 3: Exam Standard
    Let and let .
    Which of the following constraints ensure(s) that the language is context-free?
    Question 4
    2026 Slot Set2 PYQ
    Which one of the following statements is equivalent to the following assertion?

    Free preview ends here

    Login to view the complete previous-year questions and solutions

    Creating an account is free. You get the rest of this chapter, step-by-step solutions, and a study plan built around the topics you are actually weak at.

    Why MastersUp

    Personalised first. High quality throughout.

    Most platforms hand everyone the same content. Here the content moves with your performance, topic by topic.

    Built around you, not around a syllabus PDF

    Every answer you give moves your topic-level intelligence rate. The next question, the next revision card and tomorrow's plan all change with it.

    Revision that hits your weak spots

    We only revise topics you have actually attempted and are still below the safe bar on — never the same chapter on repeat.

    Questions calibrated to the real exam

    Each question carries a measured toughness. You are served a rung above your current level, so practice keeps stretching you.

    Notes written for recall, not for volume

    Full lesson cards for first study, curated short-note cards for the last mile — with derivations, traps and exam patterns marked.

    One place for everything

    Notes, chapter practice, previous-year questions, test series and full-length papers — all feeding one picture of your preparation.

    Honest progress

    No vanity streaks. Progress here means chapters mastered and accuracy that held up on harder questions.

    Unlock the whole course

    Full notes and short notes, the complete question bank with worked solutions, mock tests, full-length papers, and an adaptive plan that rebuilds itself as you improve.

    Theory of Computation PYQs for GATE CS

    GATE CS Theory of Computation: 4 chapters, 47 previous year questions (100% of Theory of Computation), 0 practice questions and one solved question from each chapter.

    About Theory of Computation Previous Year Questions (PYQs)

    47 previous year questions from Theory of Computation in GATE CS, grouped by chapter with the exam year, answer key and step-by-step solution for each.

    Theory of Computation Weightage in GATE CS

    Theory of Computation accounts for 47 of 47 Theory of Computation previous year questions in our bank (100%), about 4.7 per paper across 10 papers.

    Theory of Computation Chapter Matrix

    ChapterTopicsPYQsShare of unit PYQsPractice questions
    Finite Automata and Regular ExpressionsNFA-to-DFA Conversion and State Complexity, DFA Minimization, Distinguishability and Language Equivalence, Regular Expressions, String Counting and Divisibility Languages, Conversion between Finite Automata and Regular Expressions, DFA Design and Recognition of String Patterns1736%0
    Context-Free Grammars and Pushdown AutomataCFG Language Generation and Symbol-Count Properties, Chomsky Normal Form and Derivation Length, Grammar Ambiguity and Multiple Derivations, Pushdown Automata, Transitions and Accepted Languages1021%0
    Closure Properties and Language ClassificationRegular Language Identification and Classification, Context-Free Language Classification and Structural Constraints, Closure Properties of Language Classes1430%0
    Turing Machines, Decidability and UndecidabilityDecidable Problems for Grammars and Automata, Recursive and Recursively Enumerable Languages, Undecidable Turing Machine Language Properties, Turing Machine Deciders and Halting Behaviour613%0

    More from Theory of Computation

    One Solved Question from Each Theory of Computation Chapter

    Question 1 · Finite Automata and Regular Expressions · 2025_Set2 NAT
    Let . For , let be the product of symbols in modulo 7. We take , where is the null string.

    For example, .

    Define .

    The number of states in a minimum state DFA for is ___________. (Answer in integer)
    Correct Answer:

    6

    Step-by-Step Solution

    Key idea: This is a minimum state DFA design question based on modular arithmetic, recognizable by the "product modulo \m\" condition.

    Step 1: Identify the states needed. The DFA must remember the product of symbols modulo 7. The possible remainders are 0, 1, 2, 3, 4, 5, 6.

    Step 2: Check reachability. The alphabet is . None of these is 0 or a multiple of 7. Therefore, the product modulo 7 will NEVER be 0. The reachable states are a subset of .

    Step 3: Verify all 6 non-zero states are reachable from the start state (product = 1).

    • 1: start state ()
    • 2: read '2' ()
    • 3: read '3' ()
    • 4: read '4' ()
    • 5: read '4' then '3' ()
    • 6: read '3' then '2' ()

    All 6 states are reachable.

    Step 4: Check distinguishability. The accepting condition is . For any two distinct states and , we need a string that leads from one to 2 but not the other. Since all alphabet symbols are coprime to 7, multiplication by them is invertible modulo 7.

    • From 1, read "2"
    • From 2, read "1"
    • From 3, read "3"
    • From 4, read "4"
    • From 5, read "32"
    • From 6, read "43"

    Since every state has a path to the accepting state, and the operations are deterministic and invertible, no two states can be equivalent.

    Step 5: Conclude the number of states is exactly 6. No dead state is needed because 0 is unreachable.

    Answer: 6

    Question 2 · Context-Free Grammars and Pushdown Automata · 2026_Set2 MSQ

    Which of the following grammars is/are ambiguous?

    1. A.

    2. B.

    3. C.

    4. D.

    Correct Answer:

    ["B","C"]

    Step-by-Step Solution

    Key idea: This is a grammar ambiguity identification question. We need to check each grammar to see if any string has multiple distinct derivations.

    Step 1: Check Grammar A: S → aSb | ε

    This generates {a^n b^n | n ≥ 0}.

    For any string a^n b^n, there's only ONE way to derive it:

    • Must apply S → aSb exactly n times
    • Then apply S → ε once
    • Order is forced (always leftmost or always rightmost)

    Grammar A is UNAMBIGUOUS.

    Step 2: Check Grammar B: E → E+E | E*E | id

    This is the classic expression grammar.

    For string "id+id*id":

    Derivation 1: E ⇒ E+E ⇒ id+E ⇒ id+EE ⇒ id+idE ⇒ id+idid (groups as id + (id id))

    Derivation 2: E ⇒ EE ⇒ E+EE ⇒ id+EE ⇒ id+idE ⇒ id+idid (groups as (id + id) id)

    Two different parse trees ⇒ Grammar B is AMBIGUOUS.

    Step 3: Check Grammar C: S → aS | Sa | ε

    For string "aa":

    Derivation 1: S ⇒ aS ⇒ aaS ⇒ aa (using S → aS twice, then S → ε)

    Derivation 2: S ⇒ Sa ⇒ aSa ⇒ aa (using S → Sa, then S → aS for the first S, then S → ε)

    These are two distinct leftmost derivations for "aa".

    Grammar C is AMBIGUOUS.

    Step 4: Check Grammar D: S → aS | ε

    This generates a* (any number of a's).

    For string "aaa", there is only one leftmost derivation:

    S ⇒ aS ⇒ aaS ⇒ aaaS ⇒ aaa

    Grammar D is UNAMBIGUOUS.

    Answer: Grammars B and C are ambiguous.

    Question 3 · Closure Properties and Language Classification · 2026_Set2 MSQ
    Let and let .
    Which of the following constraints ensure(s) that the language is context-free?
    1. A.

    2. B.

      and

    3. C.

      and

    4. D.

    Correct Answer:

    ["C","D"]

    Step-by-Step Solution

    Key idea: This is a structural constraint question for Context-Free Languages, recognizable because it asks which arithmetic constraints on the exponents of a 4-part string allow it to be generated by a single stack (PDA).

    Step 1: The base string format is . A PDA processes this left-to-right. It can push symbols for the first parts and pop for the later parts. The fundamental limit is that it can only maintain ONE active nested comparison at a time.

    Step 2: Evaluate Option A: . This requires matching the sum of the first and third parts with the sum of the second and fourth parts. Because and are in the middle, a single stack cannot simultaneously track against and against in a crossed manner. This requires two independent comparisons. NOT CFL.

    Step 3: Evaluate Option B: and . This requires matching with and with . These are two independent comparisons separated by other symbols. A single stack cannot do this. NOT CFL.

    Step 4: Evaluate Option C: and . The string is . The PDA can push 's, then push 's. When reading 's, it pops 's (matching ). When reading 's, it pops 's (matching ). This is a single, perfectly nested comparison. IS CFL.

    Step 5: Evaluate Option D: . The PDA can push both 's and 's onto the stack. The total number of symbols pushed is . Then, it pops for every and every . The total number of symbols popped is . Since , the stack will empty exactly at the end. This is a single comparison of sums. IS CFL.

    Answer: C, D

    Question 4 · Turing Machines, Decidability and Undecidability · 2026_Set2 MCQ
    Which one of the following statements is equivalent to the following assertion?

    1. A.

      Turing machine halts on all input strings in

    2. B.

      Turing machine accepts all input strings in

    3. C.

      Turing machine rejects all input strings in

    4. D.

      Turing machine accepts all input strings in and rejects all input strings in