Homework 1 quick solutions
[c3] 20
ab*a | ba*b
a((bc|c)da)*
empty|ab*c
[c4] 20
see picture
[c14] 20
You could use pumping lemma or induction, straightforward.
[c15] 20
see picture
see picture
[c17]
The data structure and algorithm can be the same as for the DFA, with
just a few changes:
- each entry in the transition table bring you to not just one state,
but (possibly) a set of states
- use CLOSE on all the entries in the table
- the algorithm maintains a set of current states, rather than just one
current state
- the "next state" is the union of all the entries in the table for the
current states and the given input character
(There are also recursive solutions and/or solutions that use BFS/DFS,
but most of these do not save space (and none save time).)
NFAs could be attractive because the number of states could be much
smaller than in the corresponding DFA. A classic space/time trade-off.
Years ago, a small table might have had value so it could all fit in
memory at once. These days a small table might help cache performance.