Efficient generation of plane trees

  • Authors:
  • Shin-Ichi Nakano

  • Affiliations:
  • Gunma University/ Kiryu 376-8515, Japan

  • Venue:
  • Information Processing Letters
  • Year:
  • 2002

Quantified Score

Hi-index 0.89

Visualization

Abstract

A rooted plane tree is a rooted tree with a left-to-right ordering specified for the children of each vertex. In this paper we give a simple algorithm to generate all rooted plane trees with at most n vertices. The algorithm uses O(n) space and generates such trees in O(1) time per tree without duplications. The algorithm does not output entire trees but the difference from the previous tree. By modifying the algorithm we can generate without duplications all rooted plane trees having exactly n vertices in O(1) time per tree, all rooted plane trees having at most n vertices with maximum degree at most D in O(1) time per tree, and all rooted plane trees having exactly n vertices including exactly c leaves in O(n - c) time per tree. Also we can generate without duplications all (non-rooted) plane trees having exactly n vertices in O(n3) time per tree.