Abstract
Pruesse and Ruskey presented an algorithm for generating their Gray code for the ideals of a poset, where two adjacent ideals differ by one or two elements. Their algorithm takes O ( n ) amortized time per ideal, where n is the number of elements in the poset. Squire presented a recurrence for the ideals of a poset that enabled him to find an algorithm for generating these ideals in O ( l o g n ) amortized time per ideal, but not in Gray code order. In a recent article, we used Squire’s recurrence to find a Gray code for the ideals of a poset, where two adjacent ideals differ by one or two elements. Our algorithm, presented in a recently published article, has the same complexity as that of Pruesse and Ruskey, but it generates a Gray code that is different from the one generated by their algorithm. In this article, we generalize Squire’s recurrence. Squire’s recurrence includes a condition that enables his algorithm to run in O ( l o g n ) amortized time per ideal. We propose a less restrictive condition than his. This condition, along with our generalization of Squire’s recurrence, enabled us to improve the complexity of our algorithm. We implemented our algorithm and tested it on several examples which together illustrate most of the possible cases. We found that the running time of our program is almost the same as that of our program of Squire’s algorithm for all those posets. For most of those posets, the running time of Ruskey’s program is close to that of each of the other two programs, whereas for some posets it is much greater than that of either of the other two programs.
Published Version
Talk to us
Join us for a 30 min session where you can share your feedback and ask us any queries you have