GATE Daily

Monday26 October 2026

Past sets26 Oct 2026TOC

Regular expressions and regular languages: GATE CS question with solution

Q.8

Let be the set of all strings over the alphabet , including the empty string , that do not contain as a substring. Which one of the following regular expressions denotes exactly ?

One try. It counts in your 26 Oct 2026 set.
Show solution
RememberTo verify a regular expression for a language, look for two kinds of witness: a string in the language the expression misses, and a string the expression generates that is not in the language.

Solution MCQ · 1 mark · −⅓ if wrong

Answer: (A)

Method: describe the structure of the language, then test each option on short witnesses.

In a string with no , every is followed by an unless it is the last symbol. So the string is a sequence of blocks or , optionally followed by one final : . Conversely, gluing such blocks never puts two s together, because each block ends in .

Test the others with one string each:

Option Witness Why it fails
(b) in , but every string of (b) is empty or ends in
(c) generated as , but contains
(d) generated as , but contains

Trap. Options (c) and (d) look like harmless rearrangements of (a), but moving the optional to the wrong side of a block lets it touch another . Checking one string per option, especially strings at the boundaries (empty, ending in , starting with ), exposes this quickly.

What was tested: building a regular expression from a forbidden-substring condition and checking candidates with witness strings in both directions.

Copied. Paste it into the new chat.Too long to send. Copy the question and solution by hand.