chapter

    Theory of Computation Short Notes for Gate Cs

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

    A question from this chapter

    Question 1
    Level 3: Exam Standard

    Consider the following Assertion (A) and Reason (R).

    Assertion (A): The regular expression

    denotes exactly the binary strings whose numeric values are divisible by $3$, with considered divisible by $3$.

    Reason (R): In the standard three-state remainder DFA for divisibility by $3$, eliminating state replaces the path by the subexpression .

    Which of the following is correct?

    Question 2
    Level 3: Exam Standard

    Consider the following classes of languages over the alphabet :

    : Languages accepted by a deterministic pushdown automaton (DPDA) by empty stack.

    : Languages accepted by a DPDA by final state.

    : Languages accepted by a non-deterministic pushdown automaton (NPDA) by empty stack.

    : Languages accepted by an NPDA by final state.

    Which of the following correctly represents the relationship between these classes, where means is a proper subset of ?

    Question 3
    Level 3: Exam Standard

    Consider the following five languages over the alphabet :

    How many of these languages are regular?

    Question 4
    Level 3: Exam Standard

    Consider a Turing machine with tape alphabet and a fixed constant . Which ONE of the following properties of is IMPOSSIBLE to decide by simulating for at most steps on all inputs of length at most ?

    Free preview ends here

    Login to view the complete short notes

    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.

    Explore complete test series, official past papers, and chapter-wise study tools.

    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 Short Notes for GATE CS

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

    About Theory of Computation Short Notes

    Quick revision sheets for Theory of Computation in GATE CS. Every chapter is condensed into key formulas, shortcuts and common traps so you can revise 4 chapters fast before the exam.

    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%448
    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%276
    Closure Properties and Language ClassificationRegular Language Identification and Classification, Context-free Language Classification and Structural Constraints, Closure Properties of Language Classes1430%366
    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%180

    More from Theory of Computation

    One Solved Question from Each Theory of Computation Chapter

    Question 1 · Finite Automata and Regular Expressions MCQ

    Consider the following Assertion (A) and Reason (R).

    Assertion (A): The regular expression

    denotes exactly the binary strings whose numeric values are divisible by $3$, with considered divisible by $3$.

    Reason (R): In the standard three-state remainder DFA for divisibility by $3$, eliminating state replaces the path by the subexpression .

    Which of the following is correct?

    1. A.

      Both A and R are true, and R is a correct explanation of A

    2. B.

      Both A and R are true, but R is not a correct explanation of A

    3. C.

      A is true, but R is false

    4. D.

      A is false, but R is true

    Correct Answer:

    C

    Step-by-Step Solution

    Insight: assertion-reason questions on divisibility regexes require checking both the language claimed and the exact state-elimination formula.

    Exam route:

    Step 1: The assertion is the standard regex for binary strings divisible by $3$, with $\epsilon$ included. So A is true.

    Step 2: In the modulo-$3$ DFA, the transitions are:

    $q_0\xrightarrow{0}q_0$, $q_0\xrightarrow{1}q_1$;

    $q_1\xrightarrow{0}q_2$, $q_1\xrightarrow{1}q_0$;

    $q_2\xrightarrow{0}q_1$, $q_2\xrightarrow{1}q_2$.

    Step 3: The path $q_1\to q_2\to q_1$ uses $0$ to enter $q_2$, $1$ as the self-loop on $q_2$, and $0$ to return to $q_1$. Therefore the replacement is $01^0$, not $10^1$.

    Step 4: Hence R is false.

    Learning route:

    The standard DFA tracks remainders modulo $3$.

    From remainder $r$, reading bit $b$ moves to $(2r+b)\bmod3$.

    Thus:

    • from $q_1$, reading $0$ gives $2$, so $q_1\xrightarrow{0}q_2$;
    • from $q_2$, reading $1$ gives $(4+1)\bmod3=2$, so $q_2$ has a self-loop on $1$;
    • from $q_2$, reading $0$ gives $4\bmod3=1$, so $q_2\xrightarrow{0}q_1$.

    Eliminating $q_2$ therefore replaces the detour $q_1\to q_2\to q_1$ by $0(1)^0=01^0$.

    The reason claims $10^*1$, which swaps the entry/exit labels and the loop label, so it is false.

    The assertion is true because the full elimination yields $(0+1(01^0)^1)^*$, which accepts $0$, $11$, $1001$, etc., and rejects $1$, $10$, $100$, matching divisibility by $3$.

    Answer: A is true, but R is false.

    Tempting wrong path: memorise the final regex but misremember the eliminated subexpression as $10^*1$. That makes R look true and leads to option A or B. The break occurs at the actual edge labels in the DFA.

    Generalization: in state elimination, the replacement for a detour is always incoming-label, loop-label star, outgoing-label, in that order.

    Verification: check the detour $q_1\xrightarrow{0}q_2\xrightarrow{0}q_1$ with possible $1$-loops at $q_2$; this produces $01^*0$, confirming that R is false while A remains true.

    Question 2 · Context-Free Grammars and Pushdown Automata MCQ

    Consider the following classes of languages over the alphabet :

    : Languages accepted by a deterministic pushdown automaton (DPDA) by empty stack.

    : Languages accepted by a DPDA by final state.

    : Languages accepted by a non-deterministic pushdown automaton (NPDA) by empty stack.

    : Languages accepted by an NPDA by final state.

    Which of the following correctly represents the relationship between these classes, where means is a proper subset of ?

    1. A.

    2. B.

    3. C.

    4. D.

    Correct Answer:

    A

    Step-by-Step Solution

    Key idea: This is a language_to_math question requiring you to translate the acceptance modes of PDAs into set inclusions. The core distinction is that NPDA acceptance modes are equivalent, while DPDA acceptance modes are not.

    Step 1: Analyze NPDA equivalence. For non-deterministic PDAs, acceptance by final state and acceptance by empty stack are equivalent in power. Both accept exactly the class of Context-Free Languages (CFL). Therefore, .

    Step 2: Analyze DPDA equivalence. For deterministic PDAs, acceptance by empty stack is strictly weaker than acceptance by final state. A DPDA can accept by empty stack only if the language has the prefix property (no string is a proper prefix of another). Therefore, .

    Step 3: Compare DPDA and NPDA power. Every DPDA is an NPDA, so any language accepted by a DPDA is also accepted by an NPDA. Furthermore, there are CFLs (like ) that cannot be accepted by any DPDA. Therefore, .

    Step 4: Combine the relations. We have .

    The tempting wrong path: A student who confuses the NPDA equivalence with DPDA equivalence might think , leading to option C. Or they might think the empty stack restriction applies to NPDAs too, leading to option B or D. This breaks at Step 2 where the DPDA-specific limitation applies.

    Generalization: Always distinguish between NPDA and DPDA when reasoning about acceptance modes. The equivalence holds only for NPDAs.

    Verification: The prefix property check confirms . The standard theorem that DPDA empty-stack acceptance is strictly weaker confirms the chain of inclusions.

    Answer: A

    Question 3 · Closure Properties and Language Classification MCQ

    Consider the following five languages over the alphabet :

    How many of these languages are regular?

    1. A.

      1

    2. B.

      2

    3. C.

      3

    4. D.

      4

    Correct Answer:

    C

    Step-by-Step Solution

    Key idea: This is a pattern simplification question. When a language is defined with existentially quantified pattern variables (), the same variable appearing at multiple positions does NOT automatically create an unbounded matching requirement. You can choose the shortest valid to see what the language actually contains, UNLESS there is an explicit constraint linking the variables.

    Step 1 — Analyze : .

    Since is existentially quantified, we can choose . Let where . Then . The language contains all strings where . This is the set of all strings of length that start and end with the same character. This is described by the regular expression . Regular.

    Step 2 — Analyze : .

    Choose . Since , must be . Then is not relevant here; it's just . The language contains all strings where . This is all strings of length that start and end with . Regular expression: . Regular.

    Step 3 — Analyze : .

    The constraint explicitly links the two variables. This forces the string to be of the form where . This requires matching the number of 's before and after the 's, which is an unbounded dependency. Not regular.

    Step 4 — Analyze : .

    Choose . Let . The language contains all strings where . This is all strings of length that start and end with the same character. Regular expression: . Regular.

    Step 5 — Analyze : .

    The constraint links the variables. This forces the string to be of the form where . This means the length of the string is , and the first third of the string must exactly equal the last third. This requires matching an unbounded prefix with a suffix. Not regular.

    Count: are regular. That gives 3.

    Answer: C

    Common trap (invalid_assumption): Students often assume that because appears at multiple positions, it must be "long" or that the machine must remember the entire to verify the match. This leads them to incorrectly classify as not regular. The key insight is that existential quantification allows minimizing , which collapses the language to a simple regular form. However, this minimization trick FAILS for and because the explicit constraints and prevent independent minimization.

    Verification: For , the string can use : . For , the string uses : . The first third equals the last third .

    Question 4 · Turing Machines, Decidability and Undecidability MCQ

    Consider a Turing machine with tape alphabet and a fixed constant . Which ONE of the following properties of is IMPOSSIBLE to decide by simulating for at most steps on all inputs of length at most ?

    1. A.

      Whether halts on the input within 10 steps

    2. B.

      Whether accepts at least one string of length exactly 10 within 10 steps

    3. C.

      Whether moves its head to the right at least once on every input of length 5 within 10 steps

    4. D.

      Whether contains all strings of length at most 10

    Correct Answer:

    D

    Step-by-Step Solution

    Key idea: A property is decidable by bounded simulation if we can check it by simulating for at most steps on a finite set of inputs. If the property requires checking behavior beyond the bounded simulation space, it's impossible.

    Step 1: Analyze option (A) — "Whether halts on the input within 10 steps."

    This asks about a specific input () and a specific step bound (10 steps). We simulate on for 10 steps and check if it halts. This is DECIDABLE by bounded simulation.

    Step 2: Analyze option (B) — "Whether accepts at least one string of length exactly 10 within 10 steps."

    This asks if there exists a string of length 10 that accepts within 10 steps. There are strings of length 10. We simulate on each of these 1024 strings for 10 steps and check if any is accepted. This is DECIDABLE by bounded simulation.

    Step 3: Analyze option (C) — "Whether moves its head to the right at least once on every input of length 5 within 10 steps."

    This asks about all inputs of length 5 (there are such inputs). For each input, we simulate for 10 steps and check if the head moves right at least once. This is DECIDABLE by bounded simulation.

    Step 4: Analyze option (D) — "Whether contains all strings of length at most 10."

    This asks if contains all strings of length at most 10. There are such strings. For each string, we need to check if accepts it. However, the problem does NOT specify a step bound for acceptance. If doesn't halt on some input, we wait forever. This property requires checking unbounded behavior (whether eventually accepts each string), which is UNDECIDABLE.

    Step 5: Identify the impossible property.

    Option (D) is impossible to decide by bounded simulation because it lacks a step bound for acceptance. We cannot bound the simulation to steps.

    Answer: Whether contains all strings of length at most 10