GATE / CS ARCHIVE

GATE CSE 1995 / QUESTION 2.20

A grammar versus regular expressions for equal counts

Theory of Computation · Regular Expressions & Languages · Full GATE CSE 1995 paper

GATE 1995, Q2.20 2 marks · MCQ
Report issue

Regular Expressions & Languages

Question 2.20, GATE 1995: For L={x^n y^n:n≥1}, compare I E→xEy|xy; II xy | x⁺xyy⁺; III x⁺y⁺. Which define L?
Tap to enlarge
Your answer
Answer & solution

Answer: A: I only (no official key was published)

Grammar I starts with xy and each recursive wrapping adds one x to the front and one y to the end. It therefore generates exactly equal positive block counts. Expression III permits unequal counts, for example xyy. Expression II permits independently sized positive runs before its extra x and after its first y; for example xxyyy is accepted but has unequal counts. Hence neither regular expression enforces equality. Only I defines L, in agreement with the fact that the equal-count language is not regular.

Original paper, page 5