I need to find the grammar for the following language:
L = {a^n w w^R b^n; n >= 1, w є {a,b} and w^R is the reverse of w}
I'm really stuck on what "w є {a,b}" and "reverse of w" means.
Could someone explain this to me?
I need to find the grammar for the following language:
L = {a^n w w^R b^n; n >= 1, w є {a,b} and w^R is the reverse of w}
I'm really stuck on what "w є {a,b}" and "reverse of w" means.
Could someone explain this to me?
w є {a,b}
means that w
is in the set {a, b}
, that is, w
is either a
or b
. What I think they meant is that w
is a string consisting of a
s and/or b
s.
"reverse of w" means a string consisting of the same characters as w
, but in the opposite order. If w = abbb
, then w^R = bbba
.
L, then, is the set of strings starting with some number of a
s, followed by a palindrome consisting of an even number of a
s and b
s, and ending with the same number of b
s as there were a
s preceding the palindrome.
For example, aaaabbabbbb
would be in L: it starts with 4 a
s, ends with 4 b
s, and has abba
(w = ab
, w^R = ba
) in the middle.
aaaaababbbb
would not be in L; it has equal numbers of a
s and b
s at the beginning and end of the word, but aba
cannot be decomposed into a string followed by its own reversal.