Elsevier

Discrete Applied Mathematics

Volume 268, 15 September 2019, Pages 223-236
Discrete Applied Mathematics

Amortized efficiency of generation, ranking and unranking left-child sequences in lexicographic order

https://doi.org/10.1016/j.dam.2018.09.035Get rights and content
Under an Elsevier user license
open archive

Abstract

A new type of sequences called left-child sequences (LC-sequences for short) was recently introduced by Wu et al. (2014) for representing binary trees. They pointed out that such sequences have a natural interpretation from the view point of data structure and gave a characterization of them. Based on this characterization, there is an easily implementing algorithm that uses generate-and-test approach to filter all LC-sequences of binary trees with n internal nodes in lexicographic order, while in general it is not efficient at all. In this paper, we first design two novel rotations that allow us to drastically alter the shape of binary trees (and thus their corresponding LC-sequences). As an application, these operations can be employed to generate all LC-sequences in lexicographic order. Accordingly, we present a more efficient algorithm associated with the new types of rotations for generating all LC-sequences and show that it takes only constant amortized running cost. Moreover, we extend our study to the ranking and unranking problems. By integrating a measure called “left distances” introduced by Mäkinen (1987) to represent binary trees, we develop efficient ranking and unranking algorithms for LC-sequences in lexicographic order. With the help of aggregate analysis, we show that both ranking and unranking algorithms can be run in amortized cost of O(n) time and space.

Keywords

Binary trees
Left-child sequences
Generation algorithms
Ranking/unranking algorithms
Lexicographic order
Amortized cost

Cited by (0)

This paper combines and extends results appearing in Proceedings of the 10th International Conference on Combinatorial Optimization and Applications (COCOA 2016) and the 11th International Frontiers of Algorithmics Workshop (FAW 2017). The research was partially supported by MOST grants 107-2221-E-131-011, 107-2221-E-141-001-MY3 and 104-2221-E-262-005 from the Ministry of Science and Technology, Taiwan.