The Advantages of Forward Thinking in Generating Rooted and Free Trees

Gang Li, Department of Computer Science, University of Victoria, Canada.
Frank Ruskey, Department of Computer Science, University of Victoria, Canada.

Abstract:

We present a new approach to the exhaustive generation of rooted and free trees of n nodes. Our algorithms have the following features: (1) They are optimal in the sense of using linear space and having running times that are proportional to the number of trees produced. (2) They use a natural representation of the trees, the parent array. (3) They can generate the trees in many different orders, including reverse lexicographic order. (4) They are recursive, not iterative. (5) They can be easily modified to generate restricted classes of trees and still preserve properties (1)-(4). The possible restrictions are: (a) in the case of rooted trees, upper bounds on the number of children of a node and lower and upper bounds on the height of the tree; and (b) in the case of free trees, upper bounds on the degree of a node and lower and upper bounds on the diameter of the tree.


Selected publications that refer to this paper:
Back to list of publications.