Skip to content

GATE CS Theory of Computation questions

Practise Theory of Computation questions for GATE CS. Explore official PYQs and original subject-wise quizzes, check answers and view available solutions. Free, no sign-in.

Subject, topic, year and type filter the full library. Match any choice within a filter, and all selected filter categories. Search, source and sort apply to this page.

20 on this page
Official PYQ2024Theory of ComputationRegular Expressions and Finite AutomataNAT · 2 marks
Consider the following two regular expressions over the alphabet {0,1}\{0,1\} : r=0∗+1∗r= 0^{*}+1^{*} s=01∗+10∗s = 01^{*} + 10^{*} The total number of strings of length less than or equal to 55, which are neither in rr nor in ss, is ________.
Official PYQ2024Theory of ComputationRegular Expressions and Finite AutomataMCQ · 1 mark
​​​​Which one of the following regular expressions is equivalent to the language accepted by the DFA\text{DFA} given below?
Official PYQ2024Theory of ComputationRegular Expressions and Finite AutomataMCQ · 2 marks
​​Let M\text{M} be the 55-state NFA\text{NFA} with ϵ\epsilon-transitions shown in the diagram below. Which one of the following regular expressions represents the language accepted by M\text{M}?
Official PYQ2024Theory of ComputationRegular Expressions and Finite AutomataNAT · 2 marks
Let L1L_{1} be the language represented by the regular expression b∗ab∗(ab∗ab∗)∗b^{*} a b^{*}\left(a b^{*} a b^{*}\right)^{*} and L2={w∈(a+b)∗∣∣w∣≤4}L_{2}=\left\{w \in(a+b)^{*}|| w \mid \leq 4\right\}, where ∣w∣|w| denotes the length of string ww. The number of strings in L2L_{2} which are also in L1L_{1} is _________.
Official PYQ2023Theory of ComputationRegular Expressions and Finite AutomataMCQ · 1 mark
Consider the Deterministic Finite-state Automaton (DFA\text{DFA}) A\mathcal{A} shown below. The DFA\text{DFA} runs on the alphabet {0,1}\{0,1\}, and has the set of states {s,p,q,r}\{s, p, q, r\}, with ss being the start state and pp being the only final state. Which one of the following regular expressions correctly describes the language accepted by …
Official PYQ2023Theory of ComputationRegular Expressions and Finite AutomataMCQ · 1 mark
Consider the following definition of a lexical token id\textbf{id} for an identifier in a programming language, using extended regular expressions: …
Official PYQ2023Theory of ComputationRegular and Context-free LanguagesMSQ · 1 mark
Which of the following statements is/are CORRECT?\text{CORRECT}?
Official PYQ2023Theory of ComputationContext-free Grammars and Push-down AutomataMCQ · 2 marks
Consider the context-free grammar GG below S→aSb∣XX→aX∣Xb∣a∣b,\begin{array}{l} S \rightarrow a S b \mid X \\ X \rightarrow a X \mid X b \mid a \mid b, \end{array} where SS and XX are non-terminals, and aa and bb are terminal symbols. The starting non-terminal is SS. Which one of the following statements is CORRECT?\text{CORRECT}?
Official PYQ2023Theory of ComputationContext-free Grammars and Push-down AutomataMCQ · 2 marks
Consider the pushdown automaton (PDA)  P\text{(PDA)}\;P below, which runs on the input alphabet {a,b}\{a, b\}, has stack alphabet {⊥,A}\{\perp, A\}, and has three states {s,p,q}\{s, p, q\}, with ss being the start state. A transition from state uu to state vv, labelled c/X/γc / X / \gamma, where cc is an input symbol or ϵ,X\epsilon, X is a stack symbol, …
Official PYQ2023Theory of ComputationRegular Expressions and Finite AutomataNAT · 2 marks
Consider the language LL over the alphabet {0,1}\{0,1\}, given below: L={w∈{0,1}∗∣w does not contain three or more consecutive 1 ’s }.L=\left\{w \in\{0,1\}^{*} \mid w \text{ does not contain three or more consecutive } 1 \text{ 's }\right\} . The minimum number of states in a Deterministic Finite-State Automaton (DFA)\text{(DFA)} for LL is ____________.
Official PYQ2022Theory of ComputationRegular Expressions and Finite AutomataMCQ · 1 mark
Which one of the following regular expressions correctly represents the language of the finite automaton given below?
Official PYQ2022Theory of ComputationRegular and Context-free LanguagesMSQ · 1 mark
Which of the following statements is/are TRUE?\text{TRUE}?
Official PYQ2022Theory of ComputationContext-free Grammars and Push-down AutomataMSQ · 2 marks
Consider the following languages: L1={ww∣w∈{a,b}∗}L_{1} = \{ ww | w \in \{a,b\}^{\ast} \} L2={anbncm∣m,n≥0}L_{2} = \{a^{n} b^{n} c^{m} | m,n \geq 0 \} L3={ambncn∣m,n≥0}L_{3} = \{a^{m} b^{n} c^{n} | m,n \geq 0 \} Which of the following statements is/are FALSE?\text{FALSE}?
Official PYQ2022Theory of ComputationTuring MachinesMSQ · 2 marks
Which of the following is/are undecidable?
Official PYQ2022Theory of ComputationContext-free Grammars and Push-down AutomataMSQ · 2 marks
Consider the following languages: L1={anwan∣w∈{a,b}∗}L_{1} = \{ a^{n} wa^{n} | w \in \{a,b\}^{\ast}\} L2={wxwR∣w,x∈{a,b}∗,∣w∣,∣x∣>0}L_{2} = \{wxw^{R} | w, x \in \{a,b\}^{*}, |w|, |x| > 0 \} Note that wRw^{R} is the reversal of the string w.w. Which of the following is/are TRUE?\text{TRUE}?
Official PYQ2021Theory of ComputationContext-free Grammars and Push-down AutomataMCQ · 1 mark
Suppose that L1L_1 is a regular language and L2L_2 is a context-free language. Which one of the following languages is NOT\text{NOT} necessarily context-free?
Official PYQ2021Theory of ComputationRegular and Context-free LanguagesMCQ · 1 mark
Let ⟨M⟩\langle M \rangle denote an encoding of an automaton MM. Suppose that Σ={0,1}\Sigma = \{0,1\}. Which of the following languages is/are NOT\text{NOT} recursive?
Official PYQ2021Theory of ComputationRegular Expressions and Finite AutomataMCQ · 2 marks
Consider the following language: L={w∈{0,1}∗∣w ends with the substring 011}L= \{ w \in \{0,1\}^* \mid w \text{ ends with the substring } 011 \} Which one of the following deterministic finite automata accepts L?L?
Official PYQ2021Theory of ComputationUndecidabilityMCQ · 2 marks
For a Turing machine MM, ⟨M⟩\langle M \rangle denotes an encoding of MM. Consider the following two languages. L1={⟨M⟩∣M takes more than 2021 steps on all inputs}L2={⟨M⟩∣M takes more than 2021 steps on some input}\begin{array}{ll} L_1 = \{ \langle M \rangle \mid M \text{ takes more than } 2021 \text{ steps on all inputs} \} \\ L_2 = \{ \langle M \rangle \mid M\text{ takes more than } 2021 \text{ steps on some input} \} \end{array} Which one of the …
Official PYQ2021Theory of ComputationContext-free Grammars and Push-down AutomataNAT · 2 marks
In a pushdown automaton P=(Q,Σ,Γ,δ,q0,F)P=(Q, \Sigma, \Gamma, \delta, q_0, F), a transition of the form, where p,q∈Qp,q \in Q, a∈Σ∪{ϵ}a \in \Sigma \cup \{ \epsilon \}, and X,Y∈Γ∪{ϵ}X,Y \in \Gamma \cup \{ \epsilon \}, represents (q,Y)∈δ(p,a,X).(q,Y) \in \delta(p,a,X).Consider the following pushdown automaton over the input alphabet Σ={a,b}\Sigma = \{a,b\} and stack alphabet …