Skip to main content
Log in

Linear algorithm for lexicographic enumeration of CFG parse trees

  • Published:
Science in China Series F: Information Sciences Aims and scope Submit manuscript

Abstract

We study CFG parse tree enumeration in this paper. By dividing the set of all parse trees into infinite hierarchies according to height of parse tree, the hierarchical lexicographic order on the set of parse trees is established. Then grammar-based algorithms for counting and enumerating CFG parse trees in this order are presented. To generate a parse tree of height n, the time complexity is O(n). If τ is a lowest parse tree for its yield, then O(n) =O(∥ gt ∥+ 1), where ∥τ ∥ is the length of the sentence (yield) generated by τ. The sentence can be obtained as a by-product of the parse tree. To compute sentence from its parse tree (needn’t be lowest one), the time complexity is O(node)+O(∥τ ∥ + 1), where node is the number of non-leaf nodes of parse tree τ. To generate both a complete lowest parse tree and its yield at the same time, the time complexity is O(∥τ ∥ + 1).

This is a preview of subscription content, log in via an institution to check access.

Access this article

Price excludes VAT (USA)
Tax calculation will be finalised during checkout.

Instant access to the full article PDF.

Similar content being viewed by others

References

  1. Mäkinen E. On lexicographic enumeration of regular and context-free languages. Acta Cybernet, 1997, 13: 55–61

    MATH  MathSciNet  Google Scholar 

  2. Dömösi P. Unusual algorithms for lexicographic enumeration. Acta Cybernet, 2000, 14(3): 461–468

    MATH  MathSciNet  Google Scholar 

  3. Huang W J. Enumerating sentences of context free language based on first one in order (in Chinese). J Comput Res Dev, 2004, 41(1): 9–14

    Google Scholar 

  4. Dong Y M. Counting and hierarchical lexicographic enumeration of CFL sentences (in Chinese). Sci China Ser E-Inf Sci, 2006, 36(12): 1375–1413

    Google Scholar 

  5. Hopcroft J E, Motwani R, Ullman J D. Introduction to Automata Theory, Languages, and Computation. 3rd ed. Beijing: Pearson Education Asia Limited and China Machine Press, 2008. 171–193

    Google Scholar 

Download references

Author information

Authors and Affiliations

Authors

Corresponding author

Correspondence to YunMei Dong.

Additional information

Supported by the National Natural Science Foundation of China (Grant Nos. 60273023, 60721061)

Rights and permissions

Reprints and permissions

About this article

Cite this article

Dong, Y. Linear algorithm for lexicographic enumeration of CFG parse trees. Sci. China Ser. F-Inf. Sci. 52, 1177–1202 (2009). https://doi.org/10.1007/s11432-009-0132-7

Download citation

  • Received:

  • Accepted:

  • Published:

  • Issue Date:

  • DOI: https://doi.org/10.1007/s11432-009-0132-7

Keywords

Navigation