Assignment 5

This assignment requires you to write a finite state machine in two different ways.

First, find your student id in the list at the end, as that page contains the transition table for your finite state machine. If you cannot find your ID, email me right away, because that also means you are not on the class list!!

Interpretation of the transition tables:

The functions to create should use the following prototype:

void fsm1(char *s); /* string from symbol alphabet */
void fsm2(char *s); /* string from symbol alphabet */

You may assume that the input to fsm1 and fsm2 consist of strings that are only from the symbol alphabet

First, for fsm1, write a state machine machine using if statements to encode the transition function.

Second, for fsm2, write a state machine machine using the transtion table directly to encode the transition function. In other words, store the table in a 5x5 array and use lookup to determine the next state.

In both cases, before fsm1 or fsm2 exit, they would print ( using printf) "accept" or "reject" depending on whether the corresponding machine would accept or reject the input string.

Your program should contain a main() function which has some (hard-coded) test strings sent to both fsm1() and fsm2(). Make sure to have test cases (ie strings) that cause both 'accept' and 'reject' to be printed! In case your machine accepts all strings (or rejects all), write some explanation as to why you believe this is the case.


Deliverables: one (1) .c file saved as plain text containing the above 2 function and the main program.



Back to main page