Abstract

There are algorithms for generating combinatorial objects such as combinations, permutations and well formed parenthesis strings in O(1) time per object, in the worst case. Those known algorithms are designed based on the intrinsic nature of each problem, causing difficulty in applying a method in one area to the other. On the other hand, there are many results on combinatorial generation with minimal change order, in which just a few changes, one or two, are allowed from object to object. These results are classified in a general framework of a combinatorial Gray code, many of which are based on a recursive algorithm, causing O(n) time from object to object. To derive O(1) time algorithms for combinatorial generation systematically, we formalize the idea of combinatorial Gray code by a twisted lexico tree, which is obtained from the lexicographic tree for the given set of combinatorial objects by twisting branches depending on the parity of the nodes. An iterative algorithm which traverses this tree will generate the given set of combinatorial objects in O(1) time as well as with a fixed number of changes from the present combinatorial object to the next. Although the idea of a twisted lexico tree is not new, the mechanisms of tree traversal and computation of changing places in this paper are new. As examples of this approach, we present new algorithms for generating well formed parenthesis strings and combinations in O(1) time per object. The generation of combinations is done ‘in-place’, that is, taking O(n) space to generate combinations of n elements out of r elements. Previous algorithms take O(r) space to represent a combination by a binary vector of size r.

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call

Disclaimer: All third-party content on this website/platform is and will remain the property of their respective owners and is provided on "as is" basis without any warranties, express or implied. Use of third-party content does not indicate any affiliation, sponsorship with or endorsement by them. Any references to third-party content is to identify the corresponding services and shall be considered fair use under The CopyrightLaw.