• Home
  • Queen's University
  • Software Specifications
  • Solutions to Regular Expressions and Finite Automata Problems

Solutions to Regular Expressions and Finite Automata Problems

CISC/CMPE 223 - Assignment 1 Solutions Winter 2022 1. Question 1 Solution. (a) A · B = {0110, 0111, 010, 0010, 0011, 000, 110, 111, 10}. A . B has 9 strings. (b) B · A = {1001, 1000, 101, 1101, 1100, 111, 001, 000, 01}. B · A has 9 strings. 2. Question 2 Solution. Below several examples are given for each case (only two are required). There are infinitely many other possibilities. (a) 11, 101, 1001, 10001, 1111, 10111, 11101, .. . Explanation: Both R and S contain (10*1) *. Also e.g. 0011 € Rn S because 0011 € 00 · 10*1 ? R and 0011 € 0*10* · 0*10* C S. . (b) 00, 0000, 000000, 08, 010, . . Explanation: (00)* is a subset of R. Every nonempty string of S contains 1's. (c) 1, 01, 10, 010, 111, . . . Explanation: (0*10*)* is a subset of S. All strings of R have an even number of 1's. 3. Question 3 Solution. Again many different correct solutions are possible. (a) (0+1)*000(0 +1)*111(0+1)*+(0+1)*111(0+1)*000(0+1)* (b) (0+1)*0000(0 +1)* + (0 +1)*1111(0+1)* (c) 0110(0 +1)*0110 + 0110110 + 0110 (d) (0+10 + 110)*(€ + 1 + 11) (e) (00 +01 + 10 +11)*(0 +1)010(00+01+10+11)*+(00+01+10+11)*010(00 + 01+10+11)*(0+1) Explanation (not required): The language (00+01+10+11)*(0+1)010(00+01+ 10+11)* consists of all strings of the form w1010w2 where w1 has odd length and w2 has even length. Similarly, the second part of the union "takes care" of all strings where the prefix preceding the particular subword occurrence 010 has even length and the suffix following it has odd length. 4. Question 4 Solution. (a) Accepted: b, aba, bbb (for example) Not accepted: a, bb, bba (for example) (b) The transition table: CISC/CMPE 223 - Assignment 1 Solutions Winter 2022 a b A | B | C | A A B B C B 5. Question 5 Solution. The solution is given in Figure 1. b b a, b E a, b F c, d d b G d Figure 1: Question 5 solution. 6. Question 6 Solution. The solution is given in Figure 2 on the following page. CISC/CMPE 223 - Assignment 1 Solutions a - a A b B,C a b A,B,C a A,B Winter 2022 a B,D b a a b A,B,D b a A,B,C,D b Figure 2: Question 6 solution. b B,C,D b