Regular Expression: GATE CS Previous Year Questions

Regular Expression · Theory of Computation

19 questions · asked in 14 of 27 years (2000–2026)

MCQ 16 · MSQ 1 · NAT 21-mark 15 · 2-mark 4

2000Questions per year2026

Questions 1–5 of 19

Q1GATE 2024 (Session 1)2 marksNAT
Consider the following two regular expressions over the alphabet {0,1}\{0,1\} :

r=0∗+1∗s=01∗+10∗\begin{aligned} & r=0^*+1^* \\ & s=01^*+10^* \end{aligned}

The total number of strings of length less than or equal to 5 , which are neither in rr nor in ss, is ____

Q2GATE 2024 (Session 2)1 markMCQ−0.33 if wrong
Which one of the following regular expressions is equivalent to the language accepted by the DFA given below?
0 1 0 1

Q3GATE 2024 (Session 2)2 marksMCQ−0.67 if wrong
Let M be the 5-state NFA with ϵ\epsilon-transitions shown in the diagram below:
12345 εε00ε11
Which one of the following regular expressions represents the language accepted by M ?

Q4GATE 20231 markMCQ−0.33 if wrong
Consider the Deterministic Finite-state Automaton (DFA) AA shown below. The DFA runs on the alphabet {0, 1}, and has the set of states {s, p, q, r}, with s being the start state and p being the only final state.
s p q r 1 0 1 1 0 0 0,1
Which one of the following regular expressions correctly describes the language accepted by AA?

Q5GATE 20231 markMCQ−0.33 if wrong
Consider the following definition of a lexical token idid for an identifier in a programming language, using extended regular expressions:

letter→[A−Za−z]letter \rightarrow [A-Za-z]
digit→[0−9]digit \rightarrow [0-9]
id→letter(letter  ∣  digit)∗id \rightarrow letter (letter\;| \;digit)^*


Which one of the following Non-deterministic Finite-state Automata with - transitions accepts the set of valid identifiers? (A double-circle denotes a final state)
letter ε letter digit (A) letter ε ε letter digit (B) letter letter digit ε ε ε ε ε (C) letter letter digit ε (D)

Keep practising

Topics in Theory of Computation

All CS topics ›