Computer Science 226
Algorithms and Data Structures
Spring 2013


Course Information | Assignments | Exercises | Lectures | Exams | Precepts | Booksite

Regular Expressions

Things to Know Before Lecture

Pre-Lecture Preparation Guide.

High priority topics are in red. Medium priority topics are in green. Low priority topics are in blue.

TOPIC COURSERA BOOK SLIDES DEMO
Regular expression basics
5 45m - 15 10m 789-790 7-9
Regular Expressions and NFAs 5m 45 s - 13m
0m - 10m
794-798 19-23
24-28
Demo

Checkpoint 1: 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?

  1. AB - No, NFA is in state 5, 8, or 9. This set does not include the accept state (#11).
  2. ABD - Yes, NFA is in state 10 or 11. This set includes the accept state.
  3. BD - No. There are no valid states.
  4. AC - No. NFA is in state 8 or 9.
  5. ACD - Yes, NFA is in state 10 or 11.
  6. AACD - No. There are no valid states.