Abstract
A family of (k, m)-ary trees was firstly introduced by Du and Liu when they studied hook length polynomial for plane trees. Recently, Amani and Nowzari-Dalini presented a generation algorithm to produce (k, m)-ary trees of order n encoding by Z-sequences in reverse lexicographic order. In this paper, we propose a loopless algorithm to generate all such Z-sequences in Gray code order. Hence, the worst-case time complexity of generating one Z-sequence is $${\mathcal {O}}(1)$$ , and the space requirement of our algorithm is $$2n+{\mathcal {O}}(1)$$ . Moreover, based on this ordering, we also provide ranking and unranking algorithms. The ranking algorithm can be run in $${\mathcal {O}}(\max \{kmn,n^2\})$$ time and $${\mathcal {O}}(kmn)$$ space, whereas the unranking algorithm requires $${\mathcal {O}}(kmn^2)$$ time and space.
Talk to us
Join us for a 30 min session where you can share your feedback and ask us any queries you have
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.