CS-501 AD-501 CD-501
+3 moreAI-601 AL-601 IO-604-B
Theory of Computation

Theory of Computation Important Questions

RGPV · B.Tech · CSE · Semester 5 · Current scheme · 13 papers (2020 to 2025)

  1. Read the answers

    Start with the topics that come every year.

  2. Revise unit notes

    Go through each unit once to score more.

Paperwala Imp Topics - Theory of Computation important questions

Download Paperwala Imp Question & Answer (PDF)

Counted from the questions in the past papers listed on this site. Repeated = how many times the topic came in those papers.

Theory of Computation important questions with answers

Each answer starts with the short answer. Then come the points to write, a diagram and an exam tip. The questions under each topic are copied from the RGPV papers.

Q1. Mealy and Moore machines: difference and conversion

Asked 24 times in 2020, 2022, 2023, 2024, 2025, 2026 · Unit 1

From the papers

  • “Differentiate between Moore machine and Mealy machine with suitable examples.” (2025, 2026)
  • “Design a Moore machine to find the residue mod 2 of a binary input.” (2023, 2024)
  • “Design a Mealy machine to detect 101 in a binary stream and convert it into a Moore machine.” (2026)

The short answer

Both are finite automata with output: a Moore machine gives its output from the state alone. A Mealy machine gives it on the transition, from the state together with the current input.

Write these points

  1. Moore machine: M = (Q, Σ, Δ, δ, λ, q0) with λ: Q → Δ. The six parts are states, input alphabet, output alphabet, transition function, output function and start state.
  2. Mealy machine: the same six parts, but λ: Q × Σ → Δ.
  3. For an input of length n, a Moore machine gives n + 1 outputs because the start state also gives one. A Mealy machine gives n outputs.
  4. Moore to Mealy: for each move from p to q on a, write the output λ(q) of the state it enters on that edge. The number of states stays the same.
  5. Mealy to Moore: find every state that is entered with different outputs. Split such a state q into q/0 and q/1. Copy the outgoing moves of q to both copies. States entered with one output only are not split.
  6. Moore may need more states. Mealy reacts to the input in the same step.
PointMooreMealy
Output depends onPresent state onlyPresent state and input
Outputs for n inputsn + 1n
Number of statesOften moreOften fewer
Output writtenInside the stateOn the edge

Example.

In the figure, A on 0 goes to B with output 0 and B on 1 goes to A with output 1. A is entered with outputs 0 and 1, so it splits into A/0 and A1/1. B is entered only with output 0, so it stays one state.

Real-life example

A lift shows the floor number for the floor it is on. That is a Moore output, tied to the state. A vending machine gives a can only when the last coin goes in. That output belongs to the transition, like a Mealy machine.

Both machines print 1 when the input read so far ends in 01.
Both machines print 1 when the input read so far ends in 01.

Same or opposite: Mealy and Moore machine

PointMealyMooreSame or opposite
Output depends onState and inputState onlyOpposite
Output for input of length nn symbolsn + 1 symbolsOpposite
States neededFewerSame or moreOpposite
Finite automaton with outputYesYesSame

Exam tip. In Mealy to Moore, first list the outputs each state is entered with. Split only those states. In Moore to Mealy the edge gets the output of the target state, not the source state. Draw both machines and give the transition table for each.

Back to the topic list

Q2. Design a PDA for a given language (aⁿbⁿ, wwᴿ, wcwᴿ)

Asked 23 times in 2020, 2022, 2023, 2024, 2025, 2026 · Unit 4

From the papers

  • “Construct a PDA for L = {ww | w in (a+b)*}.” (2023, 2025)
  • “Design a PDA for L = {a^n b^n | n >= 1}.” (2023, 2025)
  • “Construct PDAs by empty stack for a^n b^m c^n (n, m >= 1) and a^n b^(2n).” (2023, 2024)

The short answer

A pushdown automaton (PDA) is a finite automaton with a stack. To design one, decide what to push while the first part of the input is read, then what to pop while the second part is read.

Write these points

  1. Formal form: M = (Q, Σ, Γ, δ, q0, Z0, F). The move δ(q, a, X) = (p, γ) means: in state q, reading a with X on top, go to p and replace X by the string γ.
  2. For aⁿbⁿ: push one a for every a. On the first b change state. Pop one a for each b. If only Z0 is left at the end, accept.
  3. Transitions for aⁿbⁿ (n ≥ 1), pushing the a's: δ(q0, a, Z0) = (q0, aZ0) and δ(q0, a, a) = (q0, aa).
  4. Popping for the b's: δ(q0, b, a) = (q1, ε) and δ(q1, b, a) = (q1, ε).
  5. Ending: δ(q1, ε, Z0) = (q2, Z0). q2 is the final state.
  6. For wcwᴿ: push every symbol of w. On c move to a pop state. Each later symbol must match the top and is popped. Only Z0 left at the end means accept. This PDA is deterministic.
  7. For wwᴿ there is no centre mark. The PDA guesses the middle with an ε-move from the push state to the pop state. So it must be non-deterministic.
  8. For aⁿb²ⁿ push two a's for each a and pop one for each b. For a²ⁿbⁿ push one for each a. On each b pop one, then pop one more with an ε-move.
  9. Acceptance can be by final state or by empty stack. Both give the same class of languages. Say which one you use.

Example.

Trace of aabb: (q0, aabb, Z0) ⊢ (q0, abb, aZ0) ⊢ (q0, bb, aaZ0) ⊢ (q1, b, aZ0) ⊢ (q1, ε, Z0) ⊢ (q2, ε, Z0). It is accepted. For aab the machine stops in q1 with a still on the stack, so it rejects.

Real-life example

When you type code, the editor checks that every opening bracket has a closing one. It pushes each ( on a stack and pops it at each ). That is exactly how a PDA accepts aⁿbⁿ.

PDA for aⁿbⁿ. A label a, X / γ means: read a, X on top, replace X by γ.
PDA for aⁿbⁿ. A label a, X / γ means: read a, X on top, replace X by γ.

Same or opposite: PDA for wcwᴿ and PDA for wwᴿ

PointwcwᴿwwᴿSame or opposite
Middle markedYes, by cNoOpposite
Type of PDADeterministicNon-deterministicOpposite
Push first half, pop second halfYesYesSame
Guess neededNoYes, where the middle isOpposite

Exam tip. Show the instantaneous descriptions for one accepted string, because the trace carries marks. Write δ as a list of moves, since a diagram alone is not enough. If {ww} is asked, write that it is not a CFL, so no PDA accepts it.

Back to the topic list

Q3. Chomsky normal form and Greibach normal form

Asked 20 times in 2020, 2022, 2023, 2024, 2025, 2026 · Unit 3

From the papers

  • “Define Chomsky normal form and Greibach normal form with examples.” (2024, 2026)
  • “Convert S -> aSb | SS | e to Chomsky normal form.” (2024, 2025)
  • “Explain CNF and GNF and compare the two normal forms.” (2026)

The short answer

A CFG is in Chomsky normal form (CNF) when every production is A → BC or A → a. It is in Greibach normal form (GNF) when every production is A → aα, with a terminal a followed by variables α.

Write these points

  1. Before either form, clean the grammar. Remove ε-productions first, then unit productions, then useless symbols.
  2. CNF step 1: in every body of length 2 or more, replace each terminal a by a new variable Ca. Add Ca → a.
  3. CNF step 2: break long bodies into pairs. A → B1B2B3 becomes A → B1D1 and D1 → B2B3.
  4. GNF step 1: rename the variables A1, A2, ..., An. Substitute until every production Ai → Ajγ has j > i.
  5. GNF step 2: remove left recursion. A → Aα | β becomes A → β | βZ with Z → α | αZ.
  6. GNF step 3: substitute back from An down to A1 so every body starts with a terminal. Then fix the Z productions the same way.
  7. In CNF a string of length n is derived in exactly 2n − 1 steps and the parse tree is binary. The CYK algorithm needs CNF.

Example.

S → aSb | ab to CNF. Add A → a and B → b, so S → ASB | AB. Break ASB with C → SB. Result: S → AC | AB, C → SB, A → a, B → b.

Real-life example

Compilers often rewrite a grammar into a fixed shape before parsing. The CYK parsing algorithm needs CNF. A top-down parser is easier to build when every rule starts with a terminal, as in GNF.

Clean the grammar first, then convert.
Clean the grammar first, then convert.

Same or opposite: CNF and GNF

PointCNFGNFSame or opposite
Rule shapeA → BC or A → aA → aαOpposite
Steps for a string of length n2n − 1nOpposite
Used byCYK algorithmTop-down parsing, PDA buildingOpposite
Every CFG without ε can be convertedYesYesSame

Exam tip. Show each step under its own heading. Marks are given step by step. An ambiguous grammar can still be put in CNF. CNF does not remove ambiguity. ε is allowed only as S → ε when ε is in the language and S is on no right side.

Back to the topic list

Q4. NFA to DFA conversion (subset construction)

Asked 18 times in 2020, 2022, 2023, 2024, 2025, 2026 · Unit 2

From the papers

  • “Explain DFA and NDFA.” (2026)
  • “Explain deterministic and non-deterministic finite automata with examples.” (2025)
  • “Convert the NDFA d(q0,a)={q0,q1}, d(q0,b)={q0}, d(q1,b)={q1}, final q1 to a DFA.” (2025)

The short answer

An NFA can go to zero, one or many states on one symbol and may have ε-moves, while a DFA has exactly one move. Every NFA has an equal DFA, found by the subset construction.

Write these points

  1. NFA: δ: Q × Σ → 2^Q (a set of states). DFA: δ: Q × Σ → Q (one state).
  2. The start state of the DFA is {q0}. With ε-moves it is ε-closure(q0), the set of states reached from q0 by ε-moves alone, q0 included.
  3. For each new subset S and each symbol a, the next state is the union of δ(q, a) for all q in S. With ε-moves, take the ε-closure of that union.
  4. Repeat only for subsets that appear. Stop when no new subset comes.
  5. A subset is final if it holds at least one final state of the NFA.
  6. An n-state NFA can need up to 2ⁿ DFA states. Both accept exactly the regular languages.
PointDFANFA
Moves per symbolExactly oneZero, one or more
ε-movesNot allowedAllowed in ε-NFA
Dead stateNeeded for a complete DFANot needed
Accepts w whenThe one path ends in FAny path ends in F
SizeCan be largeUsually smaller

Example.

NFA: δ(q0, a) = {q0, q1}, δ(q0, b) = {q0}, δ(q1, b) = {q1}, final q1. {q0} on a gives {q0, q1} and on b gives {q0}. {q0, q1} on a gives {q0, q1} and on b gives {q0} ∪ {q1} = {q0, q1}. So the DFA has two states and {q0, q1} is final.

Real-life example

A regular expression typed into a search box becomes an NFA first, because that is easy. The tool then turns it into a DFA, because a DFA runs fast with one move per character. Subset construction is that step.

The NFA from the exam question and its DFA.
The NFA from the exam question and its DFA.

Same or opposite: NFA and the DFA made from it

PointNFADFA from subset constructionSame or opposite
StatesnUp to 2ⁿOpposite
Each DFA state isOne stateA set of NFA statesOpposite
Final statesGivenAny set holding an NFA final stateOpposite
Accept the same languageYesYesSame

Exam tip. Draw the subset table first, then the DFA diagram. A subset with even one NFA final state is final. For an ε-NFA always start from the ε-closure of the start state.

Back to the topic list

Q5. Design a DFA or NFA for a given language

Asked 17 times in 2020, 2022, 2023, 2024, 2025, 2026 · Unit 2

From the papers

  • “Design a DFA accepting strings with at least 3 a's over {a,b}.” (2020, 2022, 2023)
  • “Draw the DFA over {0,1} for strings with an even number of 0's and an even number of 1's.” (2026)
  • “Design a finite automaton that checks whether a binary number is divisible by three.” (2026)

The short answer

A DFA is M = (Q, Σ, δ, q0, F) where δ: Q × Σ → Q gives exactly one next state for each state and symbol. To design one, decide what each state must remember about the input read so far.

Write these points

  1. Write a few strings that are in L and a few that are not. Then name each state by what it remembers, such as a count of a's, the last two symbols or a remainder.
  2. Binary number divisible by k: keep the remainder. New remainder = (2r + bit) mod k. You need k states and remainder 0 is final.
  3. Ends with a pattern (01, abb): each state remembers the longest suffix that is also a prefix of the pattern.
  4. Contains a substring (101, 1100): use the same idea. The last state loops on every symbol.
  5. Counting (at most 3 a's, exactly 2 a's): one state per count. Extra a's go to a dead (trap) state.
  6. Even and odd counts (even 0's and even 1's): four states for (even, even), (even, odd), (odd, even) and (odd, odd).
  7. Every state needs one move for every symbol. Add a dead state for missing moves and show it.
State01
→ q0 (final)q0q1
q1q2q0
q2q1q2

Example.

Not ending with 01: first build the DFA for 'ends with 01'. A is the start, B means the last symbol was 0, C means the input ends in 01.

Moves: A: 0 → B, 1 → A. B: 0 → B, 1 → C. C: 0 → B, 1 → A.

Now swap final and non-final states, so A and B become final.

Real-life example

A metro gate, a lift controller and the pattern search in a text editor all work as DFAs. The search for 'abb' in a file is a small DFA that remembers how much of 'abb' it has seen.

Each state is the remainder so far. q0 is both start and final.
Each state is the remainder so far. q0 is both start and final.

Same or opposite: DFA and NFA

PointDFANFASame or opposite
Moves on one symbolExactly oneZero, one or manyOpposite
ε-movesNot allowedAllowedOpposite
Accepts regular languagesYesYesSame
Easy to designHarderEasierOpposite
Easy to run in a programYesNeeds conversionOpposite

Exam tip. Give the transition table as well as the diagram. Test the DFA on two strings, one accepted and one rejected. Swapping final states gives the complement only on a complete DFA, never on an NFA.

Back to the topic list

Q6. Decidability, recursive and recursively enumerable languages

Asked 16 times in 2020, 2022, 2023, 2024, 2025, 2026 · Unit 5

From the papers

  • “Explain decidability, recursively enumerable languages and undecidable problems.” (2023, 2026)
  • “Explain decidable and undecidable languages. Discuss recursively enumerable languages.” (2025, 2026)
  • “Differentiate between decidable and recursively enumerable languages.” (2023, 2025)

The short answer

A language is recursively enumerable (r.e.) if some Turing machine accepts it, even if the machine loops on strings outside it. It is recursive (decidable) if some Turing machine accepts it and halts on every input.

Write these points

  1. Every recursive language is r.e. The opposite is false: the halting language is r.e. but not recursive.
  2. A problem is decidable if a TM always halts with the correct yes or no answer. Otherwise it is undecidable.
  3. Recursive languages are closed under union, intersection and complement. For the complement, swap the accept and reject states of a machine that always halts.
  4. R.e. languages are closed under union and intersection. They are not closed under complement.
  5. Theorem: L is recursive if and only if L and its complement are both r.e. Run both machines side by side, one step each. One of them must accept, so the combined machine always halts.
  6. Decidable: membership in a CFL, emptiness of a DFA. Undecidable: the halting problem, PCP, whether L(M) is regular, whether a TM halts on input 101.
  7. Church's thesis: whatever can be computed by an algorithm can be computed by a Turing machine.

Three languages, three answers.

L1 = binary strings with an even number of 0s. A DFA decides it and always halts, so L1 is recursive.

HALT = {(M, w) : M halts on w}. Run M on w and accept if it stops. That accepts every member, so HALT is r.e.

HALT is not recursive, because no machine can also say no on every input that loops.

The complement of HALT is not even r.e. If it were, HALT and its complement would both be r.e., making HALT recursive.

Real-life example

An antivirus program cannot decide for every program whether it will ever do harm. That question is undecidable, like the halting problem. So antivirus tools use patterns and guesses instead of a perfect test.

Recursive languages sit inside the r.e. languages.
Recursive languages sit inside the r.e. languages.

Same or opposite: recursive and recursively enumerable language

PointRecursiveRecursively enumerableSame or opposite
Turing machine haltsOn every inputOnly on strings in the languageOpposite
Also calledDecidableSemi-decidableOpposite
Complement is in the classYesNot alwaysOpposite
Accepted by a Turing machineYesYesSame

Exam tip. The whole difference is the phrase 'halts on every input'. Write it. Give one example of each class. The complement of an r.e. language that is not recursive is not even r.e.

Back to the topic list

Q7. Ambiguous grammar: test and removal

Asked 14 times in 2020, 2022, 2023, 2024, 2025, 2026 · Unit 3

From the papers

  • “What is parsing? How do leftmost and rightmost derivations help to find ambiguity?” (2023, 2024)
  • “What is ambiguity in CFG? Explain derivation trees and illustrate ambiguity.” (2026)
  • “Explain derivation trees and ambiguity in CFG with examples.” (2026)

The short answer

A CFG is ambiguous if some string has two different parse trees. Two different leftmost derivations (or two different rightmost derivations) of one string show the same thing.

Write these points

  1. To prove ambiguity give one string and two different leftmost derivations or two parse trees. One such string is a full proof.
  2. E → E + E | E * E | id: the string id + id * id has two trees (see the figure).
  3. S → aSbS | bSaS | ε: abab has two leftmost derivations. S ⇒ aSbS ⇒ abS ⇒ abaSbS ⇒ ababS ⇒ abab. Also S ⇒ aSbS ⇒ abSaSbS ⇒ abaSbS ⇒ ababS ⇒ abab.
  4. S → SS | a | b: aaa can be split as (aa)a or a(aa), so it has two trees.
  5. Removing ambiguity: there is no general method.
  6. For expressions use one variable per precedence level with left associative operators.
  7. Result: E → E + T | T, T → T * F | F, F → (E) | id.
  8. Some CFLs are inherently ambiguous, for example {aⁱbʲcᵏ | i = j or j = k}. Every grammar for them is ambiguous.
  9. Whether an arbitrary CFG is ambiguous is undecidable.

Two parse trees for id + id * id.

Grammar E → E + E | E * E | id. Derivation 1: E ⇒ E + E ⇒ id + E ⇒ id + E * E ⇒ id + id * id.

Derivation 2: E ⇒ E * E ⇒ E + E * E ⇒ id + E * E ⇒ id + id * id. Two leftmost derivations mean the grammar is ambiguous.

Put id = 2, 3, 4. Tree 1 gives 2 + (3 × 4) = 14. Tree 2 gives (2 + 3) × 4 = 20.

The grammar E → E + T | T, T → T * F | F, F → id has only the first tree. It always gives 14.

Real-life example

A calculator reading 2 + 3 × 4 must not get two answers. An ambiguous grammar would allow both 20 and 14. Precedence rules in the grammar remove the second parse tree.

Grammar E → E + E | E * E | id. Two trees for one string means ambiguous.
Grammar E → E + E | E * E | id. Two trees for one string means ambiguous.

Same or opposite: ambiguous and unambiguous grammar

PointAmbiguousUnambiguousSame or opposite
Parse trees for some stringTwo or moreExactly oneOpposite
Leftmost derivationsMore than oneOneOpposite
Good for compilersNoYesOpposite
Generates a languageYesYesSame

Exam tip. Both derivations must be leftmost, or both rightmost. One leftmost and one rightmost derivation of the same tree prove nothing. Draw the two parse trees side by side. After giving the unambiguous grammar, show that the same string now has one tree.

Back to the topic list

Q8. Types of Turing machine: universal, multitape, multihead

Asked 13 times in 2020, 2022, 2023, 2024, 2025, 2026 · Unit 5

From the papers

  • “Differentiate universal, multi-tape and multi-head Turing machines.” (2026)
  • “Compare multi-tape and multi-head Turing machines. How do they affect computational power?” (2025)
  • “Explain the different models of Turing machines.” (2024)

The short answer

A Turing machine has a finite control, an infinite tape and a read/write head that moves left or right. Its variants, such as multitape, multihead and universal machines, accept no more languages than the basic one-tape machine.

Write these points

  1. Universal Turing machine (UTM): its input is the code of any TM M together with an input w. It simulates M on w. This is the idea behind the stored program computer.
  2. Multitape TM: k tapes, each with its own head. One move reads all k symbols, writes on each tape and moves each head. A one-tape TM simulates it using tracks. Then t steps become O(t²) steps.
  3. Multihead TM: one tape with several heads. A one-tape TM simulates it by marking the head positions on extra tracks.
  4. Multidimensional TM: the tape is a grid and the head can move up, down, left or right.
  5. Two-way infinite tape, multitrack and non-deterministic TMs are also equal in power to the basic TM.
  6. Church-Turing thesis: anything computable by an algorithm is computable by a basic TM.
VariantWhat changesPower
UniversalReads the code of a TM as inputSame
Multitapek tapes, k headsSame, but faster
Multiheadk heads on one tapeSame
Non-deterministicMany possible movesSame
Linear boundedTape limited to the inputLess (context sensitive)

Why a second tape saves time.

Check if w is a palindrome, with |w| = 100.

One tape: the head runs to the far end and back for each pair of symbols. That is about 100 + 98 + ... ≈ 5,000 moves.

Two tapes: copy w to tape 2 in 100 moves, then read tape 1 forwards and tape 2 backwards. About 300 moves in all.

Both machines accept the same language. A k-tape machine that runs t steps can be copied by a one-tape machine in about t² steps.

Real-life example

A computer that runs any program you load is a universal machine. It reads the program as data, just as a universal Turing machine reads the code of another machine on its tape.

Three tapes, one control. The gold triangles mark the three heads.
Three tapes, one control. The gold triangles mark the three heads.

Same or opposite: single tape and multitape Turing machine

PointSingle tapeMultitapeSame or opposite
TapesOnek tapes, each with a headOpposite
SpeedSlowerFaster, up to a square factorOpposite
Recognises the same languagesYesYesSame
Easy to designHarderEasierOpposite

Exam tip. End each variant with 'equal in power to the basic TM'. Explain the simulation of a multitape TM in one line. It is the usual follow-up question.

Back to the topic list

Q9. Arden's theorem and regular expression from a finite automaton

Asked 16 times in 2022, 2023, 2024, 2025, 2026 · Unit 2

From the papers

  • “Explain Arden's theorem. Construct the RE of the automaton using it. Write its applications.” (2023, 2024)
  • “State and prove Arden's theorem.” (2026)
  • “Explain Arden's theorem and its use in obtaining regular expressions.” (2026)

The short answer

Arden's theorem: let P and Q be regular expressions over Σ where P does not contain ε. Then the equation R = Q + RP has exactly one solution, R = QP*.

Write these points

  1. Proof that QP* is a solution: put R = QP* on the right side. Q + QP*P = Q(ε + P*P) = QP*.
  2. Proof that it is the only one: expand R = Q + RP again and again. R = Q(ε + P + P² + ... + Pⁱ) + RPⁱ⁺¹.
  3. Take any string w in R with length i. Every string of P has length 1 or more, so every string of RPⁱ⁺¹ is longer than i.
  4. So w is in Q(ε + P + ... + Pⁱ), which is inside QP*.
  5. The same expansion shows QP* is inside R. So R = QP*.
  6. Method for an FA: it must have no ε-moves. Write one equation per state: qi = sum of qj·a over every edge from qj to qi on a. Add ε to the equation of the start state.
  7. Solve the equations by substitution and Arden's rule. The answer is the sum of the expressions of all final states.
  8. Uses: finding the RE of a finite automaton, proving two REs are equal and solving the state equations of a transition system.

Example.

For the figure: Q1 = ε + Q1·1 + Q2·1 and Q2 = Q1·0 + Q2·0. Arden on Q2 gives Q2 = Q1·00*. Put it in Q1: Q1 = ε + Q1(1 + 00*1), so Q1 = (1 + 00*1)*. The final state is Q2, so RE = (1 + 00*1)*00*. It is the set of strings that end in 0.

Real-life example

Tools like grep and form validators work with regular expressions. Arden's theorem turns a drawn automaton into such an expression, so a design on paper becomes a pattern a program can use.

One equation per state, then Arden's rule.
One equation per state, then Arden's rule.

Same or opposite: finite automaton and regular expression

PointFinite automatonRegular expressionSame or opposite
FormState diagramAlgebraic formulaOpposite
Used forRunning and testingWriting patternsOpposite
Describes regular languagesYesYesSame
Converted byArden's theorem gives an REThompson's method gives an NFAOpposite

Exam tip. Write the condition 'P does not contain ε'. Many students lose a mark here. Add ε only to the equation of the start state. With two final states, join their expressions with +.

Back to the topic list

Q10. Design a Turing machine (0ⁿ1ⁿ2ⁿ, aⁿbⁿ, 2's complement)

Asked 15 times in 2020, 2022, 2023, 2024, 2025 · Unit 5

From the papers

  • “Design a Turing machine that computes the 2's complement of a binary string. Show it on 00000.” (2023, 2025)
  • “Design a Turing machine that accepts 1^n 0^n, n > 0.” (2023, 2024)
  • “Construct a TM to accept L = {0^n 1^n 2^n | n > 0}.” (2022, 2024)

The short answer

A Turing machine is M = (Q, Σ, Γ, δ, q0, B, F) with δ: Q × Γ → Q × Γ × {L, R}. To design one, mark the symbols you have used and travel back and forth on the tape.

Write these points

  1. Idea for 0ⁿ1ⁿ2ⁿ: change the leftmost 0 to X. Move right to the first 1 and change it to Y. Move right to the first 2 and change it to Z. Move left back to X and repeat.
  2. When q0 sees Y, no 0 is left. Check that only Y and Z remain up to the blank, then accept.
  3. Mark a 0: δ(q0, 0) = (q1, X, R). Skip right: δ(q1, 0) = (q1, 0, R) and δ(q1, Y) = (q1, Y, R).
  4. Mark a 1: δ(q1, 1) = (q2, Y, R). Skip right: δ(q2, 1) = (q2, 1, R) and δ(q2, Z) = (q2, Z, R).
  5. Mark a 2 and turn back: δ(q2, 2) = (q3, Z, L).
  6. Go back left: δ(q3, s) = (q3, s, L) for s = 0, 1, Y, Z. Then δ(q3, X) = (q0, X, R).
  7. Final check: δ(q0, Y) = (q4, Y, R), δ(q4, Y) = (q4, Y, R), δ(q4, Z) = (q4, Z, R) and δ(q4, B) = (q5, B, R).
  8. δ(q0, B) = (q5, B, R) covers n = 0. q5 is final.
  9. For aⁿbⁿ drop the third symbol. Mark an a with X, mark a b with Y, come back and repeat.
  10. 2's complement: move right to the last bit. Then move left and copy bits unchanged up to and including the first 1. After that, flip every bit until the blank.
  11. A missing move means the machine halts and rejects.

Example.

Trace of 012: q0012 ⊢ Xq112 ⊢ XYq22 ⊢ Xq3YZ ⊢ q3XYZ ⊢ Xq0YZ ⊢ XYq4Z ⊢ XYZq4B ⊢ XYZBq5. The machine reaches q5, so 012 is accepted.

Real-life example

Every program on your laptop can be run by a Turing machine in principle. Marking symbols and moving back and forth on the tape is how the machine counts, much like ticking off names on a list.

A label s / t, D means: read s, write t, move D. B is the blank.
A label s / t, D means: read s, write t, move D. B is the blank.

Same or opposite: Turing machine and PDA

PointTuring machinePDASame or opposite
MemoryTape, read and write anywhereStack, top onlyOpposite
Accepts 0ⁿ1ⁿ2ⁿYesNoOpposite
Head movesLeft and rightReads input left to rightOpposite
Has a finite controlYesYesSame

Exam tip. Write the idea in two lines before the table. It earns marks even if one move is wrong. Give the transition table and an ID trace for one short string. The 2's complement of 00000 is 00000, because no 1 is found and nothing flips.

Back to the topic list

Q11. PDA model, instantaneous description, DPDA vs NPDA

Asked 15 times in 2020, 2023, 2024, 2025, 2026 · Unit 4

From the papers

  • “What is PDA? Explain instantaneous description of PDA.” (2020, 2023)
  • “Define the concept and working of push down automata.” (2026)
  • “Explain the difference between deterministic and non-deterministic PDA with examples.” (2026)

The short answer

A pushdown automaton is a finite automaton with an extra stack. M = (Q, Σ, Γ, δ, q0, Z0, F), where Γ is the stack alphabet and Z0 is the start stack symbol.

Write these points

  1. Parts: an input tape read from left to right, a finite control and a stack of unlimited size (last in, first out).
  2. A move depends on the state, the input symbol (or ε) and the top of the stack. It changes the state and replaces the top by a string, so it can push, pop or leave the stack as it is.
  3. Instantaneous description (ID): a triple (q, w, γ) holding the state, the unread input and the stack with its top on the left. (q, aw, Xβ) ⊢ (p, w, αβ) when δ(q, a, X) contains (p, α).
  4. Acceptance by final state: (q0, w, Z0) ⊢* (p, ε, γ) with p in F. Acceptance by empty stack: (q0, w, Z0) ⊢* (p, ε, ε). The two are equal in power.
  5. DPDA: for each (q, a, X) there is at most one move. Also, if δ(q, ε, X) is defined, then δ(q, a, X) is empty for every a.
  6. PDA and FA: an FA has no memory beyond its states, so it cannot count. The stack lets a PDA accept aⁿbⁿ.
PointDPDANPDA
Choices per moveAt most oneMany
LanguagesDeterministic CFLs onlyAll CFLs
Examplewcwᴿ, aⁿbⁿwwᴿ
Used inParsers (LR)Theory of CFLs

Instantaneous descriptions for aabb.

An ID is (state, input left, stack). Take the PDA for aⁿbⁿ from Q2.

(q0, aabb, Z0) ⊢ (q0, abb, aZ0) ⊢ (q0, bb, aaZ0).

(q0, bb, aaZ0) ⊢ (q1, b, aZ0) ⊢ (q1, ε, Z0) ⊢ (q2, ε, Z0). It ends in final state q2, so aabb is accepted.

wcwᴿ has a marker c, so a DPDA knows where to turn. wwᴿ has no marker, so the machine must guess the middle: it needs an NPDA.

Real-life example

When you press back in a browser, it pops the last page from a stack. A PDA uses the same stack idea to remember how many symbols it has read.

The control reads the input and pushes or pops the stack.
The control reads the input and pushes or pops the stack.

Same or opposite: DPDA and NPDA

PointDPDANPDASame or opposite
Choices per moveAt most oneManyOpposite
Accepts wwᴿNoYesOpposite
Has a stackYesYesSame
Used inParsers of programming languagesTheory of all CFLsOpposite

Exam tip. NPDA and DPDA are not equal in power. This is unlike NFA and DFA, which are equal. Write the ID with the top of the stack on the left. Draw the model with tape, control and stack.

Back to the topic list

Q12. Halting problem of Turing machine

Asked 14 times in 2022, 2023, 2024, 2025, 2026 · Unit 5

From the papers

  • “Discuss the halting problem.” (2023, 2024, 2026)
  • “Prove that no algorithm decides whether an arbitrary TM halts on input 101.” (2022, 2024)
  • “Explain the halting problem in detail.” (2026)

The short answer

The halting problem asks: given a Turing machine M and an input w, will M halt on w? No Turing machine can answer this for every M and w, so the problem is undecidable.

Write these points

  1. Suppose a machine H exists. H(M, w) always halts. It says yes if M halts on w. It says no if M does not halt on w.
  2. Build a new machine D. On input M, D runs H(M, M). If H says yes, D loops for ever. If H says no, D halts.
  3. Run D on its own code. If D halts on D, then H said no, so D does not halt. If D does not halt, then H said yes, so D halts.
  4. Both cases are contradictions. So H cannot exist. This is the diagonal argument.
  5. HALT = {(M, w) | M halts on w} is r.e. A universal TM simulates M on w and accepts when M halts. HALT is not recursive.
  6. Many problems are proved undecidable by reduction from it: M halts on input 101, M halts on some input, L(M) is regular.

Example.

Halting on 101: from (M, w) build M' that ignores its own input, writes w on the tape and runs M. M' halts on 101 exactly when M halts on w. A decider for 'halts on 101' would then decide HALT, which is impossible.

Real-life example

No tool can check every program and say whether it will hang. IDEs warn about some infinite loops, but they cannot catch all of them. The halting problem proves that no perfect checker can exist.

D does the opposite of what H predicts about it.
D does the opposite of what H predicts about it.

Same or opposite: halting problem and a decidable problem

PointHalting problemDecidable problemSame or opposite
TM that always answersDoes not existExistsOpposite
ExampleWill M halt on w?Does a DFA accept w?Opposite
Proof methodContradiction (diagonal)Give an algorithmOpposite
Is a yes or no questionYesYesSame

Exam tip. Write the contradiction in both directions. Half the marks are there. HALT is r.e., but its complement is not r.e.

Back to the topic list

Q13. P, NP, NP-complete and NP-hard problems

Asked 14 times in 2020, 2022, 2023, 2024, 2025 · Unit 5

From the papers

  • “Explain the concept of NP-complete problems with examples.” (2023, 2024, 2025)
  • “Explain the difference between tractable and intractable problems.” (2024)
  • “Explain NP hard problems in detail.” (2020)

The short answer

P is the class of decision problems a deterministic TM solves in polynomial time. NP is the class whose yes answers can be checked in polynomial time, or solved in polynomial time by a non-deterministic TM.

Write these points

  1. P ⊆ NP. Whether P = NP is still an open question.
  2. A problem X is NP-hard if every problem in NP reduces to X in polynomial time. X need not be in NP.
  3. X is NP-complete if X is in NP and X is NP-hard.
  4. Cook's theorem: SAT is NP-complete. To prove a new problem NP-complete, show it is in NP. Then reduce a known NP-complete problem to it.
  5. In P: sorting, shortest path, minimum spanning tree. NP-complete: SAT, 3-SAT, clique, vertex cover, Hamiltonian cycle, TSP (decision form). NP-hard but not in NP: the halting problem.
  6. Tractable problems have polynomial time algorithms. Intractable problems are believed to need exponential time.
  7. If any NP-complete problem gets a polynomial time algorithm, then P = NP.

Checking is fast, finding is slow.

Subset sum: numbers {3, 34, 4, 12, 5, 2}, target 9.

Certificate {4, 5}: one addition, 4 + 5 = 9, checks it. A quick check like this puts the problem in NP.

Finding it by trying every subset takes up to 2⁶ = 64 tries. With 100 numbers that is 2¹⁰⁰ tries.

SAT was the first NP-complete problem (Cook). The halting problem is NP-hard but not in NP, because it is not even decidable.

Real-life example

Checking a solved Sudoku is quick. Solving a large one from scratch can take very long. Problems that are quick to check but may be slow to solve are in NP.

NP-complete problems are the NP-hard problems that are inside NP.
NP-complete problems are the NP-hard problems that are inside NP.

Same or opposite: NP-complete and NP-hard

PointNP-completeNP-hardSame or opposite
In NPYesNot neededOpposite
Every NP problem reduces to itYesYesSame
ExampleSAT, 3-colouringHalting problem, TSP optimisationOpposite
Polynomial algorithm knownNoNoSame

Exam tip. Draw the set diagram and write that it assumes P ≠ NP. The reduction goes from the known hard problem to the new problem. Give two examples for each class.

Back to the topic list

Q14. Finite automata as language acceptor and translator

Asked 14 times in 2020, 2023, 2024, 2025, 2026 · Unit 1

From the papers

  • “Explain finite automata as a language acceptor and translator with examples.” (2023, 2025, 2026)
  • “Explain the concept of finite automata as a language acceptor.” (2025, 2026)
  • “Explain different types of automata machines in detail.” (2026)

The short answer

A finite automaton is a machine with a finite number of states that reads its input one symbol at a time. As an acceptor it answers yes or no, while as a translator it produces an output string.

Write these points

  1. Basic terms: an alphabet Σ is a finite set of symbols. A string is a finite sequence of symbols. A language is a set of strings over Σ.
  2. Acceptor: M = (Q, Σ, δ, q0, F). A string w is accepted if δ*(q0, w) is in F. The set of accepted strings is L(M).
  3. Parts of the model: an input tape divided into cells, with a reading head that moves right one cell per step.
  4. A finite control holds the current state.
  5. Translator: a machine with output (Mealy or Moore). It maps each input string to an output string, for example the 2's complement of a binary number or its residue mod 3.
  6. Types of automata: finite automata (DFA, NFA, ε-NFA), machines with output (Mealy, Moore), pushdown automata, linear bounded automata and Turing machines.
  7. Properties of δ: δ(q, ε) = q and δ(q, wa) = δ(δ(q, w), a). A trap (dead) state is a non-final state that loops to itself on every symbol.
  8. Uses: lexical analysers in compilers, text search, vending machines, traffic lights and lift controllers.

An acceptor and a translator.

Acceptor: binary numbers divisible by 3. The state is the remainder r. Each bit b gives the new r = (2r + b) mod 3.

Input 110 (that is 6): r = 0, then 1, then (2 + 1) mod 3 = 0, then 0. It ends in r = 0, so it is accepted.

Translator: a Mealy machine that outputs 1 when the input bit differs from the last one.

Input 0110 gives output 0101. The first bit has no earlier bit, so its output is 0.

Real-life example

A login form that checks an email address works as an acceptor: valid or not. A coin machine that gives change works as a translator: it turns the input coins into an output.

The same model works as an acceptor or, with an output, as a translator.
The same model works as an acceptor or, with an output, as a translator.

Same or opposite: acceptor and translator

PointAcceptorTranslatorSame or opposite
OutputAccept or rejectA string of symbolsOpposite
Has final statesYesNot neededOpposite
ExamplesDFA, NFAMealy, Moore machineOpposite
Has finite statesYesYesSame

Exam tip. Draw the block diagram with tape, head and finite control. Give one acceptor example (a DFA) and one translator example (a Mealy machine) in the same answer.

Back to the topic list

Q15. Conversion of CFG to PDA and PDA to CFG

Asked 13 times in 2022, 2023, 2024, 2025, 2026 · Unit 4

From the papers

  • “Explain the conversion of CFG into PDA with an example.” (2026)
  • “Describe the conversion from PDA to CFG using the standard algorithm.” (2025)
  • “Convert S -> 0S1 | A, A -> 1A0 | S | e into a PDA accepting by empty stack.” (2025)

The short answer

For every CFG there is a PDA that accepts the same language, while for every PDA there is a CFG. So PDAs accept exactly the context free languages.

Write these points

  1. CFG to PDA (one working state, empty stack): first put S on the stack with δ(q, ε, Z0) = (q, SZ0).
  2. Expand: for each production A → α add (q, α) to δ(q, ε, A).
  3. Match: for each terminal a add δ(q, a, a) = (q, ε).
  4. The PDA accepts when the input is read and the stack is empty. Its moves follow a leftmost derivation.
  5. PDA to CFG (PDA accepting by empty stack): use variables [p X q]. It means the PDA starts in p with X on top, reads some input, pops X and ends in q.
  6. Add S → [q0 Z0 q] for every state q. For δ(p, a, X) containing (r, ε) add [p X r] → a.
  7. For δ(p, a, X) containing (r, Y1Y2...Yk) add [p X sk] → a[r Y1 s1][s1 Y2 s2]...[sk−1 Yk sk] for every choice of states s1 to sk. Then remove useless variables.

Example.

Grammar: S → aABB | aAA, A → aBB | a, B → bBB | A.

One move per variable: δ(q, ε, S) = {(q, aABB), (q, aAA)}, δ(q, ε, A) = {(q, aBB), (q, a)}.

Also δ(q, ε, B) = {(q, bBB), (q, A)}.

One move per terminal: δ(q, a, a) = (q, ε) and δ(q, b, b) = (q, ε).

Real-life example

A parser generator such as YACC takes a grammar and builds a stack-based parser from it. That is the CFG to PDA conversion done by a tool.

Expand moves replace a variable. Match moves pop a terminal.
Expand moves replace a variable. Match moves pop a terminal.

Same or opposite: CFG to PDA and PDA to CFG

PointCFG to PDAPDA to CFGSame or opposite
InputGrammarAutomatonOpposite
DifficultySimple, one stateHarder, variables [pXq]Opposite
Shows CFG and PDA have equal powerYesYesSame
Result sizeSmallMany productionsOpposite

Exam tip. In CFG to PDA write one expand move per production and one match move per terminal. In PDA to CFG a push of k symbols with n states gives nᵏ productions. Show the pattern, then drop the useless ones. Say which acceptance you use: empty stack is the usual one for these conversions.

Back to the topic list

How we picked these questions

RGPV teaches Theory of Computation to 6 branches under one syllabus. Each branch prints its own code on the paper, but the units are the same. So one page and one PDF serve all of them.

We counted every question in the Theory of Computation papers on this site by topic, from 2020 to 2026. A topic that keeps coming back is a topic RGPV likes, so it sits higher in the table. One branch alone has only a few papers. Counting them together gives a surer list.

Theory of Computation important questions by branch

CS-501 Theory of Computation important questions for CSE, Semester 5

CS-501 follows the same RGPV syllabus as the other codes on this page. The 15 topics and answers above are the CS-501 important questions too.

See all 13 CS-501 previous year papers

AD-501 Theory of Computation important questions for AI & Data Science, Semester 5

AD-501 follows the same RGPV syllabus as the other codes on this page. The 15 topics and answers above are the AD-501 important questions too.

See all 2 AD-501 previous year papers

CD-501 Theory of Computation important questions for CSE-DS, Semester 5

CD-501 follows the same RGPV syllabus as the other codes on this page. The 15 topics and answers above are the CD-501 important questions too.

See all 4 CD-501 previous year papers

AI-601 Theory of Computation important questions, Semester 6

AI-601 follows the same RGPV syllabus as the other codes on this page. The 15 topics and answers above are the AI-601 important questions too.

See all 3 AI-601 previous year papers

AL-601 Theory of Computation important questions for CSE-AIML, Semester 6

AL-601 follows the same RGPV syllabus as the other codes on this page. The 15 topics and answers above are the AL-601 important questions too.

See all 3 AL-601 previous year papers

IO-604-B Theory of Computation important questions for IOT, Semester 6

IO-604-B follows the same RGPV syllabus as the other codes on this page. The 15 topics and answers above are the IO-604-B important questions too.

See all 2 IO-604-B previous year papers

About Theory of Computation

Theory of Computation (CS-501) asks what a computer can and cannot do, using simple machines as models. It is a Semester 5 subject of RGPV B.Tech CSE with five units that climb from finite automata to the Turing machine. Draw each machine as you learn it, because most questions ask you to build one.

Theory of Computation unit-wise brief

Unit 1: Introduction to automata theory

This unit introduces automata with examples, finite automata as language acceptors and translators, Moore and Mealy machines, composite machines, and conversion between Mealy and Moore machines. Practise one conversion each way.

Unit 2: Types of finite automata

Here you study non-deterministic (NDFA) and deterministic (DFA) finite automata, converting an NDFA to a DFA, minimising automata, regular expressions and Arden's theorem. It also covers union, intersection, concatenation, closure and the 2-way DFA. NDFA to DFA conversion is a standard question, so learn the table method.

Unit 3: Grammars

This unit covers types of grammar (regular, context free and context sensitive), derivation trees, ambiguity, simplifying a context free grammar, converting between grammars and automata, the Chomsky hierarchy, removing null and unit productions, and Chomsky and Greibach normal forms. Do each simplification step in order.

Unit 4: Push down automata

A push down automaton (PDA) is a finite automaton with a stack. The unit covers examples of PDA, deterministic and non-deterministic PDA, converting a PDA into a context free grammar and back, and the Petri net model. Trace a PDA on a short string, writing the stack at every step.

Unit 5: Turing machine

The last unit covers how to build a Turing machine, the universal Turing machine, multitape, multihead and multidimensional machines, NP-complete problems, decidable and undecidable languages, recursively enumerable languages, the halting problem and the post correspondence problem. Know the halting problem's statement and why it cannot be solved.

Units follow the RGPV scheme and syllabus, B.Tech Computer Science and Engineering, Semester 5 (AICTE flexible curriculum, w.e.f. July 2019). For the full topic list of each unit, open the Theory of Computation notes.

Start with the latest papers

Theory of Computation - Dec 2025

Theory of Computation - Jun 2025

Theory of Computation - Dec 2025

See all 13 papers →

Theory of Computation (CS-501) FAQs

What are the most important topics in Theory of Computation?

By how often they were asked in the papers on this site: Mealy and Moore machines: difference and conversion (24 times); Design a PDA for a given language (aⁿbⁿ, wwᴿ, wcwᴿ) (23 times); Chomsky normal form and Greibach normal form (20 times); NFA to DFA conversion (subset construction) (18 times); Design a DFA or NFA for a given language (17 times).

How were these Theory of Computation important questions chosen?

Each topic was counted from the questions in the past papers listed on this site (2020-2026). Repeated is the number of times the topic came. The counts come from keyword matching and the answers are not teacher-reviewed, so use them together with your syllabus.

Is there a PDF of Theory of Computation important questions with answers?

Yes. The Paperwala Imp Question & Answer PDF for Theory of Computation is free to download from this page.

The 15 most repeated topics of Theory of Computation (CS-501) for RGPV B.Tech CSE semester 5, counted from the previous year papers on this site. The same syllabus is taught under 6 codes: CS-501, AD-501, CD-501, AI-601, AL-601, IO-604-B. Theory of Computation is also searched for as CS-505.

Also known as CS-505