GATE / CS ARCHIVE

SIMILAR QUESTIONS / THEORY OF COMPUTATION

Reduce existential reversed borders to short witnesses

3 questions solved the same way, newest first. Back to Theory of Computation

How these are solved

For w x reverse(w) with nonempty w and free middle, test whether a one-symbol border already witnesses membership. Respect source-specific nonempty conditions; accompanying language classifications differ.

2 marks · MSQ
Report issue

Regular Expressions & Languages

Question 47, GATE 2022: Over Σ={a,b}, L1={a^n w a^n : w∈Σ*}, L2={w x w^R : w,x∈Σ*, |w|,|x|>0}. Select true statements: A both regular; B both context-free; C L1 regular and L2 context-free; D both context-free but neither regular. The source does not explicitly state the allowed n in L1.
Tap to enlarge
Select all that apply
Answer & solution

Official answer: A,B,C

In L1 the arbitrary middle word absorbs all content: if n=0 is allowed, L1=Σ*; if n is required positive, taking n=1 gives aΣ*a. Either reading is regular. L2 consists exactly of strings of length at least 3 whose first and last symbols agree: take w to be the first symbol and x the nonempty middle. Hence L2=aΣ+a ∪ bΣ+b is regular. Both are therefore context-free as well, so A, B, C are true and D is false.

For L2, any allowed decomposition has equal first and last symbols and at least one middle symbol. Conversely if those conditions hold, choose |w|=1 and put everything else in x. Longer equal/reversed boundary strings are optional witnesses, not extra restrictions. This existential choice is why the language is much simpler than a general palindrome language.

Original paper, page 31 · Answer key

2 marks · MCQ
Report issue

Regular Expressions & Languages

Question 46, GATE 2015: Which languages are regular? L1={wxw^R:w, x∈{a, b}*, |w|, |x|>0}; L2={a^n b^m:m≠n, m, n≥0}; L3={a^p b^q c^r:p, q, r≥0}. A L1, L3; B L2 only; C L2, L3; D L3 only.
Tap to enlarge
Your answer
Answer & solution

Official answer: A

L1 consists exactly of length≥3 strings with equal first/last symbols: choose the one-symbol w and nonempty interior x. Its regex is a(a+b)(a+b)*a + b(a+b)(a+b)*b, so regular. If L2 were regular, subtracting it from a*b* would make{an bn} regular, contradiction. L3=a*b*c* is regular. Thus L1, L3, A.

In L1, the first and last symbols must agree because w and its reversal surround x. Conversely, any length≥3 string with equal ends can choose a one-symbol w and the nonempty middle as x, so that simple description is exact and regular. L2 is the unequal-count complement within a*b*. If it were regular, subtracting it from regular a*b* would make the equal-count language regular, contradicting its pumping argument. L3 has the direct regular expression a*b*c*. Thus A contains exactly the regular choices.

Original paper, page 41 · Answer key

2 marks · MCQ
Report issue

Regular language among palindrome-based forms

Regular Expressions & Languages

Question 31, GATE 2007: Which language is regular? In all options w and x are nonempty binary strings, w^R is the reversal of w, and Σ={0,1}.
Options:
(A) {ww^R:w∈Σ+}
(B) {ww^R x:w,x∈Σ+}
(C) {wxw^R:w,x∈Σ+}
(D) {xww^R:w,x∈Σ+}
Tap to enlarge
Your answer
Answer & solution

Answer: C (no official key was published)

1. Approach. The existential decomposition matters: for option C, w can always be chosen to have length one. This removes the apparent need to remember an arbitrarily long prefix. A direct regular expression is 0(0|1)+0 | 1(0|1)+1.

2. Derivation and interpretation. In C, every string wxwR has the same first and last symbol and length at least 3. Conversely any binary string of length≥3 with equal endpoints has such a representation by choosing w to be its first single symbol and x its nonempty middle. Thus C equals 0(0+1)+0 ∪1(0+1)+1 and is regular. A is the nonempty even-palindrome language and nonregular. For B, intersect with the regular language 0(11)*1 00 (11)*1 01. The result is{0 1k 00 1k 01:k positive odd}: the only possible even-palindrome prefix must match the two odd-length 1 blocks. This equality language is nonregular by pumping the first block. Hence B is nonregular. D is the reversal of B and is likewise nonregular.

Original paper, page 7