go to previous page   go to home page   go to next page

Answer:

Here is a RE   Z*Z+   and here is a string it matches:  ZZZZ .

What part of the string does   Z*  match?

ZZZ — it must leave the last "Z" so the Z+ has something to match.

Is there a simpler RE that matches the same set of strings?

Z+

Non-determinism

Here is a RE A+A+ and here is the automaton that matches it

Non-deterministic Finite Automaton

The automaton is non-deterministic. If (for example) the automaton is in state q1 and the current character is 'A' it has a choice of transitions. "Greedy" behavior is that the automaton will stay in q1 unless doing so will prevent it from reaching the final state.

A non-deterministic automaton matches a string if there is a possible path through it that consumes each of the characters in the string. Not all paths have to match the string.


QUESTION 23:

Here is a regular expression: [ABC]*[CD]

Does the expression match these strings?

StringABCCBCCCDCDDCCAACCCCCAACAB
Match or
Reject?