CSC262 Theory of Computation

Theory of ComputationTU Board 2078

Give the regular expressions for the following language over alphabet a, b. 1. Set of all strings with substring bab or abb. 1. Set of all strings whose 3^rd symbol is 'a' and 5^th symbol is 'b'.

10

Give the regular expressions for the following language over alphabet {a, b}.

  1. Set of all strings with substring bab or abb.
  2. Set of all strings whose 3^rd symbol is 'a' and 5^th symbol is 'b'.

Answer

Alphabet Σ = {a, b}.

1. All strings containing the substring bab or abb

Any string, then one of the two substrings, then any string:

(a + b)* (bab + abb) (a + b)*

For example, aabba contains abb and bbabb contains bab, and both match.

2. All strings whose 3rd symbol is a and 5th symbol is b

Positions 1, 2 and 4 can be anything, position 3 must be a, position 5 must be b, and the rest can be anything:

(a + b)(a + b) a (a + b) b (a + b)*

For example, bbaab and abaabba match; aabab does not, because its 3rd symbol is b.

Discussion

Loading…

More Theory of Computation questions

All Theory of Computation old questions