part 1.bSaSa means that a should be preceeded by atleast one occurence of b and followed by atleast one occurrence of a.
part 2.bPa means a double occurrence of either a or b
part 3.aQ means zero or one occurrence of a.
So in all the strings these rules need to be followed.We will break the strings into 3 part so that application of all the rules can be examined efficiently.
- bbaaabba -
bb-a-aa part 1
bb means part 2 double occurence of b and a is part 3 one occurence of a So it belongs to the given regular expression.
2. baaabb
b-a-aa part 1 satisfied bb part 2 satisfied zero occurrence of a part 3 satisfied . So it also belongs to the regular expression.
3. bbbaaaa
bbb-a-a part 1 satisfied aa part 2 satisfied zero occurrence of a part 3 satisfied . So it also belongs to the regular expression
4. baabbaaaa
b-a-a part1 bb-part 2 but aaaa doesnt account here . So it does not belong to the regular expression.