A simple way to construct NFA with fewer states and transitions

The problem of converting a regular expression to NFA is a fundamental problem that has been well studied. However, the two basic construction algorithms: (1) Thompson, (2) McNaughton-Yamada and Glushkov, does not yield the best solution in terms of the number of states and transitions. In this paper, we show: For a regular expression with l literals, we can construct an NFA with 2l states and 4l transitions in the worst case. Our algorithm runs in linear time with respect to the length of the regular expression. This improves the construction algorithm given by Chang in [5], which constructs an NFA with 5l=2 states and (10l -- 5)/2 transitions in the worst case. The method presented here is much simpler and easier to understand, as we use only naive ideas: divide and conquer.