A few practice FSM problems

advertisement
COMP SCI 242 Discrete Mathematics II
A few practice FSM problems.
F. Baulieu
1) Design a FSM with input alphabet {0, 1} and output alphabet { 0, 1, 2, 3 } that will
echo the first bit it encounters, and thereafter will ouput the decimal value of the binary
string formed by the two most recent input bits.
E.g. input: 010011 will produce
output: 012013
0→0
01→1
10→2
00→0
01→1
11→3
2) Design a FSM over {0, 1} that will output 1 if the first bit and the current bit of the
input string are equal, 0 otherwise.
E.g. input : 010011 will produce
output: 101100
3) Design a FSM over { 0, 1, b } that will output a copy of the input string except that
the first bit will have been moved to the end of the string. (“b” represents a blank” here )
E.g. . input : 010011 will produce
output: 100110
4) Design a FSM over { 0, 1, 2, 3 } that will output the largest input digit read so far.
E.g.
input : 001032 will produce
output: 001133
5) Design a FSA over { 0, 1 } that will accept a string iff it contains a substring of 5
alternating bits.
E.g. 11010001010100 would be accepted.
6) Design a FSA over {a, b, c } that accepts strings iff they contain a double-a OR they
contain a double-b, OR they do NOT contain a double-c.
Download