REGULAR EXPRESSIONS STUDY GUIDE


Terminology and Basics

NFA Simulation NFA Construction

Recommended Problems

C level

  1. Consider the regular expression
    ((A|B)DA*C)
    Circle all words matched by this regular expression.
    ABDAC ADAAC ABDACA BDC BDAC AACA Answers
  2. Textbook 5.4.1, 5.4.2

B level

  1. Fall 2011 Final, #7
  2. Which of the following (if any) are true reasons why we usually prefer NFAs for matching a regular expression (RE), as opposed to DFAs?

    The size of the NFA is linear in the size of the RE, while the size of the DFA might be as bad as quadratic.

    The size of the NFA is linear in the size of the RE, while the size of the DFA might be as bad as exponential.

    The running time to simulate the NFA is linear in the size of the RE, while the running time for the DFA might be as bad as quadratic.

    The running time to simulate the NFA is linear in the size of the RE, while the running time for the DFA might be as bad as exponential.

    The NFA only has two kinds of transitions (match and e), while the DFA requires determining the correct transition for each possible input character.

    The DFA might require backing up in the input stream, while the NFA does not. Answers

  3. Textbook 5.4.16, 5.4.17, 5.4.18

A level

None!