skip to main content
10.1145/986537.986588acmconferencesArticle/Chapter ViewAbstractPublication Pagesacm-seConference Proceedingsconference-collections
Article

A simple way to construct NFA with fewer states and transitions

Published:02 April 2004Publication History

ABSTRACT

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.

References

  1. A. Aho. Pattern matching in strings. In Formal Language Theory(R. Book ed). Academic Press, 1980.Google ScholarGoogle Scholar
  2. V. Antimirov. Partial derivatives of regular expressions and finite automata construction. Theoretical Computer Science, 155:291--319, 1996. Google ScholarGoogle ScholarDigital LibraryDigital Library
  3. J. H. A. Aho and J. Ullman. The Design and Analysis of Computer Algorithms. Addison-Wesley, Reading, Mass., 1974. Google ScholarGoogle ScholarDigital LibraryDigital Library
  4. G. Berry and R. Sethi. From regular expressions to deterministic automata. Theoretical Computer Science, 48:117--126, 1986. Google ScholarGoogle ScholarDigital LibraryDigital Library
  5. C. Chang. Ph.D Thesis. Department of Computer Science, Courant Institute, New York, 1992.Google ScholarGoogle Scholar
  6. G. C. C. Clark. On the use of regular expressions for searching text. ACM Trans. on Programming Languages and Systems, 19(3):413--426, 1997. Google ScholarGoogle ScholarDigital LibraryDigital Library
  7. V. Glushkov. The abstract theory of automata. Russian Math. Surveys, 16:1--53, 1961.Google ScholarGoogle ScholarCross RefCross Ref
  8. P. P. G. Apostolopoulos, V. Peris. L5: A self learning layer 5 switch. In Technical Report RC21461. IBM, T.J. Watson Research Center, 1999.Google ScholarGoogle Scholar
  9. R. McNaughton and H. Yamada. Regular expressions and state graphs for automata. Trans. IRS, EC(9):39--47, 1960.Google ScholarGoogle Scholar
  10. E. Meyer. A four-russians algorithm for regular expression pattern matching. Journal of ACM, 39(2):432--448, 1992. Google ScholarGoogle ScholarDigital LibraryDigital Library
  11. K. Thompson. Regular expression search algorithm. Communications of the ACM, 11(6):410--422, 1968. Google ScholarGoogle ScholarDigital LibraryDigital Library
  1. A simple way to construct NFA with fewer states and transitions

    Recommendations

    Comments

    Login options

    Check if you have access through your login credentials or your institution to get full access on this article.

    Sign in
    • Published in

      cover image ACM Conferences
      ACM-SE 42: Proceedings of the 42nd annual Southeast regional conference
      April 2004
      485 pages
      ISBN:1581138709
      DOI:10.1145/986537
      • General Chair:
      • Seong-Moo Yoo,
      • Program Chair:
      • Letha Hughes Etzkorn

      Copyright © 2004 ACM

      Permission to make digital or hard copies of all or part of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for components of this work owned by others than ACM must be honored. Abstracting with credit is permitted. To copy otherwise, or republish, to post on servers or to redistribute to lists, requires prior specific permission and/or a fee. Request permissions from [email protected]

      Publisher

      Association for Computing Machinery

      New York, NY, United States

      Publication History

      • Published: 2 April 2004

      Permissions

      Request permissions about this article.

      Request Permissions

      Check for updates

      Qualifiers

      • Article

      Acceptance Rates

      Overall Acceptance Rate134of240submissions,56%
    • Article Metrics

      • Downloads (Last 12 months)3
      • Downloads (Last 6 weeks)0

      Other Metrics

    PDF Format

    View or Download as a PDF file.

    PDF

    eReader

    View online with eReader.

    eReader