Computer Science 226
Algorithms and Data Structures
Course Information |
Things to Know Before Lecture
- The syntax of regular expressions.
- How to manually tell if a string matches a regular expression.
- How to write a regular expression to meet a simple spec.
- Optional but recommended:
- What an NFA is.
- How to read an NFA diagram (red arrows and black arrows).
- How to simulate an NFA manually to test if a string matches a regular expression.
Pre-Lecture Preparation Guide.
High priority topics are in red. Medium priority topics are in green. Low priority topics are in blue.
How many bitstrings of length exactly 1,000 match the regular expression 0(0 | 1)*1?
Answer (highlight to see): 2998 - in English, the regular expression matches for any bit string that starts with 0 and ends with 1. That leaves 998 unspecified characters in the middle which may be either 0 or 1.
Checkpoint 2 (optional but recommended): Given the NFA below, which of the following strings match? What is the set of possible states that the DFA could reach with this input?
- AB - No, NFA is in state 5, 8, or 9. This set does not include the accept state (#11).
- ABD - Yes, NFA is in state 10 or 11. This set includes the accept state.
- BD - No. There are no valid states.
- AC - No. NFA is in state 8 or 9.
- ACD - Yes, NFA is in state 10 or 11.
- AACD - No. There are no valid states.