IAE Academy

GATE 2025 CS1 Q.44: solution and answer

GATE 2025 · CS1Q.44 · 2 marks · MCQ

Consider the following two languages over the alphabet :

Which ONE of the following statements is CORRECT?

  1. (A)

    Both and are regular languages.

  2. (B)

    is a regular language but is not a regular language.

  3. (C)

    is not a regular language but is a regular language.

  4. (D)

    Neither nor is a regular language.

See the question in the paper

Answer and solution

ANSWER

is not regular, but is regular, so the answer is (C).

Official answer: CSource: Official answer key, GATE 2025 CS1 (IIT Roorkee)

  1. is regular. Every string of has the form with and , so it starts with , ends with and has length at least . Conversely, any string with is in : take and . Hence , which is regular.

  2. is not regular. A string is in exactly when it has a nonempty border (a string that is both a prefix and a suffix of ) with , so that a nonempty fits between the two copies. We use the Myhill-Nerode theorem on the strings for .

  3. Take and the suffix . Then with and , so .

  4. Now consider , of length . It starts with , so any border starts with and ends with . A suffix starting with is either with (taken from the last block), or with (taken from the first block).

  5. If the border is , the prefix of the same length must be (the word begins ), which forces . But , a contradiction. If the border is , its prefix starts with , which forces , and then the border is the whole word, which is not a proper border. So has no valid border and .

  6. Thus for every pair the suffix separates from . The strings () are pairwise distinguishable, so has infinitely many Myhill-Nerode classes and is not regular.

  7. Therefore is not regular and is regular, which is option (C).

KEY IDEA

collapses to the regular language because the single letter can always serve as . In , can be any nonempty word, so the language demands a long matching border, and Myhill-Nerode on shows it is not regular.

WATCH OUT FOR

Seeing the same at both ends and assuming both languages need unbounded memory, or assuming both are regular because the first and last letters match. In a border can start and end with different letters, for example with , so is not just "first letter equals last letter". Also, the separating suffix must be chosen from the smaller index: fails for because is then also a border of .

From the GATE 2025 CS1 paper. Every question of this paper · Download the full paper · All 5 Regular languages questions, with notes

More Regular languages questions