GATE CS Theory of Computation PYQ with Solutions
Also searched as: GATE TOC PYQ · GATE Automata PYQ · GATE Formal Languages PYQ
All 46 Theory of Computation questions from every GATE Computer Science (CS/CSE) paper from 2021 to 2026, both sets where there were two, with the official answer key and a step-by-step solution. Theory of Computation carries about 7.3 marks per paper on average. Questions are grouped chapter-wise, newest paper first.
| 2026 | 2025 | 2024 | 2023 | 2022 | 2021 |
|---|---|---|---|---|---|
| 5.5 | 7.5 | 7 | 8 | 8 | 8.5 |
Theory of Computation: Regular Grammar — GATE CS PYQ (25)
- GATE CS 2026 Set 1 · Q26Theory of Computationmsq1 markLet M be a nondeterministic finite automaton (NFA) with 6 states over a finite alphabet. Which of the following options CANNOT be the number of states in the minimal deterministic finite automaton (DFA) that is equivalent to ?
- A.32
- B.65✓
- C.1
- D.128✓
Open GATE CS 2026 Set 1 Q26 · discuss this question →Answer: B, D
Solution
Answer: B, D Subset construction gives at most DFA states, and the minimal DFA can be no larger. So 65 and 128 are impossible. 1 is possible (for example or ), and so is 32, since anything from 1 to 64 can occur. - A.
- GATE CS 2026 Set 1 · Q51Theory of Computationmsq2 marksLet and be two languages over a finite alphabet, such that and are regular languages. Which of the following statements is/are always true?
- A.is regular
- B.is regular
- C.is context-free✓
- D.is context-free
Open GATE CS 2026 Set 1 Q51 · discuss this question →Answer: C
Solution
Answer: C Take . Then is regular for any , even an undecidable one. • (A) and (D) fail for such an . • (B) , which also fails. • (C) is always true: every regular language is context-free. - A.
- GATE CS 2026 Set 2 · Q47Theory of Computationmsq2 marksConsider the following two finite automata and . Which of the following statements is/are true?

- A.
- B.is a proper subset of
- C.✓
- D.consists of all strings in whose length is divisible by 3✓
Open GATE CS 2026 Set 2 Q47 · discuss this question →Answer: C, D
Solution
Answer: (C), (D) Tracing both automata: and are different languages (so (A) is false) and neither is contained in the other (so (B) is false). Both accept only the empty string in common, so — (C) true. Every non-empty accepted string of either machine has length a multiple of 3, and closing under concatenation yields exactly all strings of length divisible by 3 — (D) true. - A.
- GATE CS 2025 Set 1 · Q28Theory of Computationmsq1 markA regular language is accepted by a non-deterministic finite automaton (NFA) with states. Which of the following statement(s) is/are FALSE?
- A.may have an accepting NFA with states.
- B.may have an accepting DFA with states.
- C.There exists a DFA with states that accepts .
- D.Every DFA that accepts has states.✓
Open GATE CS 2025 Set 1 Q28 · discuss this question →Answer: D
Solution
Answer: (D) — this is the FALSE statement. By the subset construction, an -state NFA has an equivalent DFA with at most states. So (C) is true, and (D) ("every DFA has more than states") is false — in fact the minimal DFA often has far fewer. (A) and (B) are true possibilities: the given NFA/DFA need not be minimal, so may have an accepting NFA or DFA with fewer than states. - A.
- GATE CS 2025 Set 1 · Q44Theory of Computationmcq2 marksConsider the following two languages over the alphabet :Which ONE of the following statements is CORRECT?
- A.Both and are regular languages.
- B.is a regular language but is not a regular language.
- C.is not a regular language but is a regular language.✓
- D.Neither nor is a regular language.
Open GATE CS 2025 Set 1 Q44 · discuss this question →Answer: C
Solution
Answer: (C) is not regular but is regular. is regular. Since consists only of 's, we can always take (a single ) and let be the middle. So is exactly the set of strings that start with , end with , and have length — described by the regular expression . is not regular. Here may be any non-empty string, and the same must appear as both a prefix and a suffix. When the first and last symbols differ (e.g. ), a single-symbol border no longer works, and the automaton would have to match an arbitrarily long prefix against the suffix — which a finite automaton cannot do (provable by the pumping lemma). Hence is not regular. - A.
- GATE CS 2025 Set 1 · Q50Theory of Computationmsq2 marksConsider the deterministic finite automaton (DFA) shown, over . Identify which of the following language(s) is/are accepted by the given DFA.

- A.The set of all strings containing an even number of 's.
- B.The set of all strings containing the pattern .
- C.The set of all strings ending with the pattern .✓
- D.The set of all strings not containing the pattern .
Open GATE CS 2025 Set 1 Q50 · discuss this question →Answer: C
Solution
Answer: (C) The set of all strings ending with the pattern . The DFA is the standard 4-state minimal automaton that tracks the longest suffix matching a prefix of : (nothing) () () (, accepting); with , , , and the self-loops shown. The only accepting state is reached exactly after reading a suffix . If another follows, leaves the accepting state — so e.g. "" contains but is rejected, ruling out (B). The DFA accepts precisely strings ending in . (A) and (D) are easily refuted by the same automaton. - A.
- GATE CS 2025 Set 2 · Q30Theory of Computationmsq1 markConsider List I and List II:
For matching items in List I with List II, which of the following option(s) is/are CORRECT?List I | List II (i) Context free langs | (a) Closed under union (ii) Recursive langs | (b) Not closed under complementation (iii) Regular langs | (c) Closed under intersection- A.(i)-(a), (ii)-(b), (iii)-(c)
- B.(i)-(b), (ii)-(a), (iii)-(c)✓
- C.(i)-(b), (ii)-(c), (iii)-(a)✓
- D.(i)-(a), (ii)-(c), (iii)-(b)
Open GATE CS 2025 Set 2 Q30 · discuss this question →Answer: B, C
Solution
Answer: (B) and (C) Key facts: CFLs are closed under union but NOT under complementation (or intersection). Recursive languages are closed under union, intersection and complementation. Regular languages are closed under all three. - (B): (i)-(b) CFL not closed under complementation ✓, (ii)-(a) recursive closed under union ✓, (iii)-(c) regular closed under intersection ✓. - (C): (i)-(b) ✓, (ii)-(c) recursive closed under intersection ✓, (iii)-(a) regular closed under union ✓. Both matchings assign each class a property it genuinely satisfies, so (B) and (C) are both correct. (A) and (D) assign CFLs a closure (intersection/union pairing with the wrong exclusivity) that is inconsistent. - A.
- GATE CS 2025 Set 2 · Q52Theory of Computationmsq2 marksLet and for , denote the number of 's in . Which one or more of the following define regular language(s)?
- A.✓
- B.
- C.✓
- D.
Open GATE CS 2025 Set 2 Q52 · discuss this question →Answer: A, C
Solution
Answer: (A) and (C) - (A) is regular. ✓ - (B) Intersecting with forces to be empty, i.e. , giving — NOT regular. - (C) Track and with a finite automaton of states → regular. ✓ - (D) requires counting and is NOT regular. - A.
- GATE CS 2025 Set 2 · Q60Theory of Computationnat2 marksLet . For , is the product of the symbols modulo 7 (with ). Define . The number of states in a minimum-state DFA for is ___________. (Answer in integer)Open GATE CS 2025 Set 2 Q60 · discuss this question →
Answer: 6
Solution
Answer: 6 Track the running product modulo 7. The symbols are all non-zero mod 7, so the product is always a unit — it lives in the multiplicative group , which has 6 elements. Starting from , these symbols (e.g. 3 is a generator) can reach every residue in , and each residue leads to different acceptance behaviour, so all 6 are distinct, non-mergeable states (0 is never reachable). The accepting state is residue . Minimum DFA has states. - GATE CS 2024 Set 1 · Q23Theory of Computationmsq1 markLet be regular and not regular. Which statements are always TRUE?
- A.iff
- B.is not regular
- C.is not regular✓
- D.is regular✓
Open GATE CS 2024 Set 1 Q23 · discuss this question →Answer: C, D
Solution
Answer: (C) and (D) - (C) If were regular, then would be regular (regular languages are closed under complement) — contradiction. So is not regular. TRUE. - (D) Regular languages are closed under complement and union, so is regular. TRUE. - (A) FALSE: iff , i.e. ; one half being empty is not enough. - (B) FALSE: e.g. non-regular but gives , regular. - A.
- GATE CS 2024 Set 1 · Q50Theory of Computationmsq2 marksConsider the 5-state DFA shown (state 1 is start and accepting). Which statements is/are FALSE?

- A.States 2 and 4 are distinguishable in M
- B.States 3 and 4 are distinguishable in M✓
- C.States 2 and 5 are distinguishable in M✓
- D.Any string w with n0(w)=n1(w) is in L(M)
Open GATE CS 2024 Set 1 Q50 · discuss this question →Answer: B, C
Solution
Answer: (B) and (C) From the diagram, reading 0's cycles and reading 1's cycles . The DFA tracks , with accepting state 1 (residue 0). - States 2 and 4 both are "one step from accept" but on opposite symbols; they turn out equivalent/ distinguishable as the structure dictates: 2 and 4 are distinguishable (A true). - States 3 and 4: both need one more appropriate symbol to reach accept and behave identically under the residue counting -> indistinguishable -> statement (B) "distinguishable" is FALSE. - States 2 and 5 similarly are indistinguishable -> statement (C) is FALSE. - (D): any with gives residue 0 -> state 1 -> accepted, so (D) is TRUE. - A.
- GATE CS 2024 Set 1 · Q61Theory of Computationnat2 marksFor and over , the number of strings of length that are neither in nor in is _________Open GATE CS 2024 Set 1 Q61 · discuss this question →
Answer: 44
Solution
Answer: 44 = all-0 or all-1 strings (including ). = a 0 followed by any number of 1's, or a 1 followed by any number of 0's. Total strings of length to . Subtracting those in (11 strings: and for ) and those in (strings of the two forms, length 1..5) and adding back none (the two sets are disjoint except trivially), the count of strings in neither is . - GATE CS 2024 Set 2 · Q22Theory of Computationmcq1 markWhich regular expression is equivalent to the language accepted by the DFA shown (states over )?

- A.✓
- B.
- C.
- D.
Open GATE CS 2024 Set 2 Q22 · discuss this question →Answer: A
Solution
Answer: (A) From the DFA, strings reach the accepting state by first taking any number of 0's then a 1 (), after which the self/return transitions allow repeating patterns of a single or a followed by : . This exactly describes the accepted language. - A.
- GATE CS 2024 Set 2 · Q41Theory of Computationmcq2 marksThe 5-state NFA (with -transitions) shown accepts which language?

- A.
- B.✓
- C.
- D.
Open GATE CS 2024 Set 2 Q41 · discuss this question →Answer: B
Solution
Answer: (B) Tracing the NFA: from the start there are -moves to a branch counting 0's (loop of two 0's, with accept allowing -like behaviour) and a branch for a 1 followed by pairs of 1's. Combining the accepting paths yields , matching option (B). - A.
- GATE CS 2024 Set 2 · Q62Theory of Computationnat2 marksis given by and . The number of strings in that are also in is __________Open GATE CS 2024 Set 2 Q62 · discuss this question →
Answer: 15
Solution
Answer: 15 is exactly the set of strings over with an ODD number of 's. Counting strings of length with an odd number of 's:
Total .length 1: a -> 1 length 2: ab, ba -> 2 length 3: 1 a (C(3,1)=3) + 3 a (C(3,3)=1) -> 4 length 4: 1 a (C(4,1)=4) + 3 a (C(4,3)=4) -> 8 - GATE CS 2023 · Q14Theory of Computationmcq1 markConsider the DFA shown over with states , start state , and the only final state. Which regular expression describes ?

- A.
- B.
- C.✓
- D.
Open GATE CS 2023 Q14 · discuss this question →Answer: C
Solution
Answer: (C) From , only a leading reaches the final state . From , reading a keeps you in the accepting cycle, and reading (via and back) returns to ; any other symbol goes to the dead state . So accepted strings are a followed by any sequence of 's and 's: . - A.
- GATE CS 2023 · Q24Theory of Computationmsq1 markWhich statements are CORRECT?
- A.The intersection of two regular languages is regular.✓
- B.The intersection of two context-free languages is context-free.
- C.The intersection of two recursive languages is recursive.✓
- D.The intersection of two recursively enumerable languages is recursively enumerable.✓
Open GATE CS 2023 Q24 · discuss this question →Answer: A, C, D
Solution
Answer: (A), (C) and (D) Regular, recursive, and recursively enumerable languages are all closed under intersection -> (A),(C),(D) true. Context-free languages are NOT closed under intersection (e.g. is the intersection of two CFLs but is not context-free) -> (B) false. - A.
- GATE CS 2023 · Q63Theory of Computationnat2 marksThe minimum number of states in a DFA for does not contain three or more consecutive 1's is __________Open GATE CS 2023 Q63 · discuss this question →
Answer: 4
Solution
Answer: 4 Track the number of trailing 1's: state (0 trailing 1's / reset), (one trailing 1), (two trailing 1's) — all accepting — and a dead state reached on the third consecutive 1. That is 4 states, and they are pairwise distinguishable, so 4 is minimum. - GATE CS 2022 · Q12Theory of Computationmcq1 markWhich regular expression represents the language of the finite automaton shown?

- A.
- B.
- C.
- D.✓
Open GATE CS 2022 Q12 · discuss this question →Answer: D
Solution
Answer: (D) The automaton has a start state branching into two accepting loops: one reached by reading then cycling on 's (and returning via ), the other by reading then cycling on 's (returning via ). Reading the accepting paths and their self-loops yields the expression in option (D), which captures both symmetric accepting branches. - A.
- GATE CS 2022 · Q23Theory of Computationmsq1 markWhich statements are TRUE?
- A.Every subset of a recursively enumerable language is recursive.
- B.If a language L and its complement are both recursively enumerable, then L is recursive.✓
- C.Complement of a context-free language must be recursive.✓
- D.If L1 and L2 are regular, then L1-L2 must be deterministic context-free.✓
Open GATE CS 2022 Q23 · discuss this question →Answer: B, C, D
Solution
Answer: (B), (C) and (D) - (B) If and are both RE, run both semi-deciders in parallel; one halts, deciding -> recursive. True. - (C) CFLs are recursive, and recursive languages are closed under complement, so is recursive. True. - (D) Regular languages are closed under difference, so is regular, hence deterministic context-free. True. - (A) False: a subset of an RE (even of a recursive) language can be non-recursive. - A.
- GATE CS 2021 Set 1 · Q48Theory of Computationmcq2 marksConsider the following language.Which one of the following deterministic finite automata accepts ? (See the figure for options (A)–(D).)

- A.(A)
- B.(B)
- C.(C)
- D.(D)✓
Open GATE CS 2021 Set 1 Q48 · discuss this question →Answer: D
Solution
A correct DFA for strings ending in 011 needs the accepting state reached only after reading 0,1,1 in order, with proper back-transitions on mismatches. Only option (D) has the correct transitions and single accepting state for this pattern. - A.
- GATE CS 2021 Set 2 · Q19Theory of Computationmcq1 markLet be a regular language whose minimal DFA has exactly states. Which one of the following languages is guaranteed to have a minimal DFA with exactly states?
- A.
- B.
- C.(the complement of )✓
- D.
Open GATE CS 2021 Set 2 Q19 · discuss this question →Answer: C
Solution
Complementing a DFA only swaps accepting and non-accepting states, keeping the same (already minimal) set of states, so the complement also has exactly states. - A.
- GATE CS 2021 Set 2 · Q27Theory of Computationnat1 markConsider the deterministic finite automaton (DFA) shown in the figure. The number of strings of length 8 accepted by the above automaton is ______.
Open GATE CS 2021 Set 2 Q27 · discuss this question →Answer: 256
Solution
From the start state, after reading any two symbols the automaton reaches the accepting state, and the accepting state has self-loops on both and . Hence every string of length is accepted; for length 8 there are strings. - GATE CS 2021 Set 2 · Q46Theory of Computationmcq2 marksConsider the following two statements about regular languages. : Every infinite regular language contains an undecidable language as a subset. : Every finite language is regular. Which one of the following choices is correct?
- A.Only is true
- B.Only is true
- C.Both and are true✓
- D.Neither nor is true
Open GATE CS 2021 Set 2 Q46 · discuss this question →Answer: C
Solution
An infinite language has uncountably many subsets but only countably many are decidable, so it must contain an undecidable subset — is true. Every finite language is regular (a finite union of single-string languages) — is true. - A.
- GATE CS 2021 Set 2 · Q57Theory of Computationmsq2 marksWhich of the following regular expressions represent(s) the set of all binary numbers that are divisible by three? Assume that the string is divisible by three.
- A.✓
- B.✓
- C.✓
- D.
Open GATE CS 2021 Set 2 Q57 · discuss this question →Answer: A, B, C
Solution
Building the DFA that tracks the remainder modulo 3 and converting it to a regular expression, options (A), (B) and (C) each generate exactly the binary strings whose value is divisible by 3 (including ); (D) does not. - A.
Theory of Computation: Context Free Grammar — GATE CS PYQ (16)
- GATE CS 2026 Set 1 · Q25Theory of Computationmsq1 markConsider the following grammar where is the start symbol, and and are terminal symbols.Which of the following statements is/are true?
- A.The grammar is ambiguous✓
- B.The string has two distinct derivations in this grammar✓
- C.The string has only one rightmost derivation✓
- D.The language generated by the grammar is undecidable
Open GATE CS 2026 Set 1 Q25 · discuss this question →Answer: A, B, C
Solution
Answer: A, B, C "abb" has two parse trees. In , the extra b can come from either or : Two distinct trees make the grammar ambiguous, so (A) and (B) are true. (C) "abab": the first symbol forces , so must give "bab". Either (possible), or (impossible, because every a needs a later matching b). There is only one tree, so only one rightmost derivation. True. (D) False: the language is context-free, and every CFL is decidable.
- A.
- GATE CS 2026 Set 1 · Q52Theory of Computationmsq2 marksConsider the following context-free grammar .In the above grammar, is the start symbol, and are terminal symbols, and and are non-terminal symbols. Let be the language generated by the grammar . For a string , let be the number of ’s in and be the number of ’s in . Which of the following statements is/are true?
- A.There is a string such that
- B.For every string ,✓
- C.There is a string such that
- D.For every string ,✓
Open GATE CS 2026 Set 1 Q52 · discuss this question →Answer: B, D
Solution
Answer: B, D Track (#a, #b) for each non-terminal. • with : equal a's and b's. • : adds a:3, b:2 plus a balanced , so . • : adds a:2, b:1 plus balanced s, so +1 more per step. Every has . • : the terminals "aba" and "bba" give a:3, b:3, so . So always: (B) true, (A) false. Ratio check: each block keeps : the block, a:3 ≤ 2·2, a:2 ≤ 2·1, and a:3 ≤ 2·3. Sums of such blocks keep the bound, so (D) is true and (C) false. - A.
- GATE CS 2026 Set 2 · Q48Theory of Computationmsq2 marksLet and let . Which of the following constraints ensure(s) that the language is context-free?
- A.✓
- B.and
- C.and✓
- D.✓
Open GATE CS 2026 Set 2 Q48 · discuss this question →Answer: A, C, D
Solution
Answer: (A), (C), (D) - (A) : a single balance condition — can be checked with one stack counter. CF ✓ - (B) and : two independent, interleaved comparisons ( and ) — needs two stacks. Not CF ✗ - (C) and : nested matching — a single stack suffices. CF ✓ - (D) : one balance condition. CF ✓ - A.
- GATE CS 2025 Set 1 · Q19Theory of Computationmcq1 markConsider the following context-free grammar , where are the variables (non-terminals), and are the terminal symbols, is the start variable, and the rules of are:
Which ONE of the languages is accepted by ?S -> aaB | Abb A -> a | aA B -> b | bB- A.✓
- B.
- C.
- D.
Open GATE CS 2025 Set 1 Q19 · discuss this question →Answer: A
Solution
Answer: (A) generates (one or more 's); generates . - with . - with . Their union is exactly option (A). - A.
- GATE CS 2025 Set 1 · Q45Theory of Computationmcq2 marksConsider the following two languages over , where are natural numbers:Which ONE of the following statements is CORRECT?
- A.Both and are context-free languages.
- B.is a context-free language but is not a context-free language.
- C.is not a context-free language but is a context-free language.✓
- D.Neither nor are context-free languages.
Open GATE CS 2025 Set 1 Q45 · discuss this question →Answer: C
Solution
Answer: (C) is not context-free but is context-free. is context-free. We need . A PDA (or grammar) pushes one symbol for each and each , then pops one for each :
This generates . is not context-free. It requires and , i.e. two independent comparisons tied to . A single stack can match 's with 's, but after that the count is lost and cannot be compared again with the 's. By the pumping lemma for CFLs (pump ), fails to be context-free.S -> a S c | B B -> b B c | b c - A.
- GATE CS 2025 Set 2 · Q24Theory of Computationmcq1 markWhich ONE of the following languages is accepted by a deterministic pushdown automaton?
- A.Any regular language.✓
- B.Any context-free language.
- C.Any language accepted by a non-deterministic pushdown automaton.
- D.Any decidable language.
Open GATE CS 2025 Set 2 Q24 · discuss this question →Answer: A
Solution
Answer: (A) Any regular language. Every regular language is a deterministic context-free language, hence accepted by a DPDA. DPDAs accept exactly the deterministic CFLs — a strict subset of all CFLs — so they cannot accept every CFL (B), every NPDA language (C), or every decidable language (D). - A.
- GATE CS 2024 Set 1 · Q59Theory of Computationnat2 marksis in Chomsky Normal Form with 10 variables. The string () is derivable from . The number of steps in is _________Open GATE CS 2024 Set 1 Q59 · discuss this question →
Answer: 179
Solution
Answer: 179 In CNF every production is or . For a string of length , deriving it takes exactly binary rule applications (to build a binary tree with leaves) plus terminal rule applications steps. For : . - GATE CS 2024 Set 2 · Q52Theory of Computationmsq2 marks: , , . For , with the counts of , which statements is/are TRUE?
- A.
- B.✓
- C.✓
- D.
Open GATE CS 2024 Set 2 Q52 · discuss this question →Answer: B, C
Solution
Answer: (B) and (C) Each use of adds one and one ; adds an ; and each eventually becomes a . Counting: every comes with the rule, and the number of 's is always one more than the number of 's -> (C). Since each has a matching (plus possibly extra 's), , and relating to gives (B). (A) fails when no rule is used and (D) is false in general. - A.
- GATE CS 2023 · Q39Theory of Computationmcq2 marksConsider : , . Which statement is CORRECT?
- A.
- B.✓
- C.
- D.is not a regular language
Open GATE CS 2023 Q39 · discuss this question →Answer: B
Solution
Answer: (B) generates (any number of leading 's, one middle symbol, any number of trailing 's — at least one symbol). The rule wraps matched 's and 's around, but these are absorbed into the form. So , which is regular. - A.
- GATE CS 2023 · Q40Theory of Computationmcq2 marksThe PDA shown (states , start , accepts by empty stack) runs on . Which language does it accept?

- A.✓
- B.
- C.
- D.
Open GATE CS 2023 Q40 · discuss this question →Answer: A
Solution
Answer: (A) In state each 'a' pushes an (so at least one is needed, ). Reading 'b' moves to and pops one per . To empty the stack and accept, at least one must still be removed by an epsilon-transition after the 's - so there must be strictly more 's than 's, i.e. . Hence the language is . - A.
- GATE CS 2022 · Q47Theory of Computationmsq2 marksand . Which is TRUE?
- A.L1 and L2 are regular.✓
- B.L1 and L2 are context-free.✓
- C.L1 is regular and L2 is context-free.✓
- D.L1 and L2 are context-free but not regular.
Open GATE CS 2022 Q47 · discuss this question →Answer: A, B, C
Solution
Answer: (A), (B) and (C) Both languages are in fact REGULAR. - : taking already gives all strings that start and end with 'a' (with a non-empty middle), so collapses to a regular language. - : taking , for a single char - i.e. every string of length whose first and last characters are equal - which is regular. Since both are regular (hence also context-free): (A) both regular, (B) both context-free, and (C) L1 regular and L2 context-free are all TRUE; (D) is false because L1 is regular. - A.
- GATE CS 2022 · Q48Theory of Computationmsq2 marks, , . Which statements are FALSE?
- A.L1 is not context-free but L2 and L3 are deterministic context-free.
- B.Neither L1 nor L2 is context-free.✓
- C.L2, L3 and L2 ∩ L3 all are context-free.✓
- D.Neither L1 nor its complement is context-free.✓
Open GATE CS 2022 Q48 · discuss this question →Answer: B, C, D
Solution
Answer: (B), (C) and (D) is not context-free; are deterministic context-free (single matching). is NOT context-free. - (A) True (as stated). - (B) FALSE: IS context-free. - (C) FALSE: is not context-free. - (D) FALSE: the complement of IS context-free (a known result). So (B), (C), (D) are the false statements. - A.
- GATE CS 2021 Set 1 · Q11Theory of Computationmcq1 markSuppose that is a regular language and is a context-free language. Which one of the following languages is NOT necessarily context-free?
- A.
- B.
- C.✓
- D.
Open GATE CS 2021 Set 1 Q11 · discuss this question →Answer: C
Solution
Regular CFL, regular CFL and regular CFL are all CFLs. But , and the complement of a CFL need not be a CFL, so is not necessarily context-free. - A.
- GATE CS 2021 Set 1 · Q61Theory of Computationnat2 marksIn a pushdown automaton , a transition of the form shown represents . Consider the pushdown automaton over the input alphabet and stack alphabet shown in the figure. The number of strings of length 100 accepted by the above pushdown automaton is ______.
Open GATE CS 2021 Set 1 Q61 · discuss this question →Answer: 50
Solution
The PDA pushes an for each and pops one for each , and reaches the accepting state only while an remains, i.e. it accepts with . For we need , i.e. — exactly 50 strings. - GATE CS 2021 Set 2 · Q22Theory of Computationmsq1 markLet be a regular language and be a context-free language. Which of the following languages is/are context-free?
- A.
- B.✓
- C.✓
- D.✓
Open GATE CS 2021 Set 2 Q22 · discuss this question →Answer: B, C, D
Solution
, so (C) is — regular, hence context-free. In (D), and are each (regular CFL) = CFL, and the union of CFLs is a CFL. Per the official GATE key, (B) is also accepted. Option (A) () need not be context-free. - A.
- GATE CS 2021 Set 2 · Q51Theory of Computationmsq2 marksFor a string , we define to be the reverse of . For example, if then . Which of the following languages is/are context-free?
- A.
- B.✓
- C.✓
- D.✓
Open GATE CS 2021 Set 2 Q51 · discuss this question →Answer: B, C, D
Solution
(B) is a concatenation of two even-palindrome languages and (D) is a nested palindrome structure — both CFL. (C) equals (take ), which is regular, hence CFL. (A) has crossing dependencies between the two reversed parts and is not context-free. - A.
Theory of Computation: Undecidability — GATE CS PYQ (5)
- GATE CS 2026 Set 2 · Q13Theory of Computationmcq1 markWhich one of the following statements is equivalent to the following assertion? Turing machine decides the language
- A.Turing machine halts on all input strings in
- B.Turing machine accepts all input strings in
- C.Turing machine rejects all input strings in
- D.Turing machine accepts all input strings in and rejects all input strings in✓
Open GATE CS 2026 Set 2 Q13 · discuss this question →Answer: D
Solution
Answer: (D) A TM decides iff it is a total machine that halts on every input, accepting exactly the strings in and rejecting exactly the strings not in . Only option (D) captures both the accept and the reject requirement (and thus halting on all inputs). - A.
- GATE CS 2025 Set 2 · Q25Theory of Computationmcq1 markLet be Context-Free Grammars and a regular expression. Which ONE among the following questions is decidable?
- A.Is ?
- B.Is ?
- C.Is ?
- D.Is ?✓
Open GATE CS 2025 Set 2 Q25 · discuss this question →Answer: D
Solution
Answer: (D) Is ? Emptiness of a CFG is decidable (check whether the start symbol can derive any terminal string). The others are undecidable for CFGs: equivalence of two CFGs, emptiness of intersection of two CFLs, and equivalence of a CFG with a regular language. - A.
- GATE CS 2022 · Q46Theory of Computationmsq2 marksWhich of the following is/are undecidable?
- A.Given Turing machines M1, M2, decide if L(M1)=L(M2).✓
- B.Given a Turing machine M, decide if L(M) is regular.✓
- C.Given a Turing machine M, decide if M accepts all strings.✓
- D.Given a Turing machine M, decide if M takes more than 1073 steps on every string.
Open GATE CS 2022 Q46 · discuss this question →Answer: A, B, C
Solution
Answer: (A), (B) and (C) Equivalence of two TMs (A), whether is regular (B), and whether accepts all strings / (C) are all undecidable (by Rice's theorem for the language properties, and reduction for equivalence). (D) is DECIDABLE: run for 1073 steps on all strings up to length 1073 — a finite check determines whether it ever halts within 1073 steps. - A.
- GATE CS 2021 Set 1 · Q22Theory of Computationmsq1 markLet denote an encoding of an automaton . Suppose that . Which of the following languages is/are NOT recursive?
- A.is a DFA such that
- B.is a DFA such that
- C.is a PDA such that
- D.is a PDA such that✓
Open GATE CS 2021 Set 1 Q22 · discuss this question →Answer: D
Solution
DFA emptiness, DFA universality and PDA emptiness are all decidable (recursive). PDA/CFG universality () is undecidable, so (D) is not recursive. - A.
- GATE CS 2021 Set 1 · Q49Theory of Computationmcq2 marksFor a Turing machine , denotes an encoding of . Consider the following two languages.Which one of the following options is correct?
- A.Both and are decidable.✓
- B.is decidable and is undecidable.
- C.is undecidable and is decidable.
- D.Both and are undecidable.
Open GATE CS 2021 Set 1 Q49 · discuss this question →Answer: A
Solution
In at most 2021 steps a TM can read only the first 2021 input cells, so the behaviour depends on finitely many input prefixes. Both conditions can be checked by simulating for 2021 steps on these finitely many relevant inputs, so both and are decidable. - A.
Take a Theory of Computation chapter-wise test
Pick any chapters and attempt their PYQs with a timer in the GATE interface, with instant analysis — free.
Create free account →