Past Issues

Studies in Informatics and Control
Vol. 13, No. 4, 2004

Gray Code Algorithm for Listing k-ary Trees*

H. Ahrabian, A. Nowzari-Dalini, E. Salehi
Abstract

In this paper an efficient algorithm for generating k-ary trees in Gray code order is presented. This algorithm is an extended form of the constant time algorithm developed by Vajnovszki to enumerate Gray codes for binary trees. In our algorithm the k-ary trees are represented by bitstring sequences. The generation algorithm is based on moving in a Hamiltonian path of a graph, which each vertex of it is labeled with a bitstring corresponding to a k-ary tree. Clearly, the Gray code property of the vertices construct the edges of this graph. The algorithm generates two successor codes in constant delay time.

Keywords

k-ary tree, Gray codes, Constant time generation algorithm.

View full article