On the Rotation Distance in the Lattice of Binary Trees

A natural idea to compare tree structures is to compute a distance based on the least number of admissible transformations needed to transform a tree into another [8]. Distance measures of leastmoves type are conceptually simple, yet computationally difficult [2]. In this paper, as in [4], the basis for the distance measure is the well-known rotation tree transformation [7]. In a previous paper [10], it is proved that this rotation induces a lattice structure on binary trees. Unfortunately, algebraic results cannot be used since this lattice is neither modular nor graded [5,8]. Using the weight sequences introduced in [10], we give an O(n 2) algorithm for computing efficient lower and upper bounds of the rotation distance. The rotation distance can exactly be computed using an admissible searching Algorithm D*, which uses the lower bound as an evaluation function. tively external) node. The weight q; of a tree T is the number of external nodes of T. Let B~ denote the set of binary trees with n internal nodes (i.e., n + 1 external nodes). The external nodes of a tree T are numbered by a pre-order traversal of T. Given T ~ B n, the weight sequence of T is the integer sequence (WT(1), WT(2),...,wT(n)) where WT(i ) is the weight of the largest subtree of T, whose last external node is the external node i [10]. An ordered pair of integers (i, j ) is said to be a segment of a tree T if there exists a subtree of T with i (respectively j) as first (respectively last) external node. Every T ~ B~ has n segments (i, j ) satisfying the following properties (where we set WT(n + I) = n + 1):