70 research outputs found

    A constant-time algorithm for middle levels Gray codes

    Get PDF
    For any integer n≥1n\geq 1 a middle levels Gray code is a cyclic listing of all nn-element and (n+1)(n+1)-element subsets of {1,2,…,2n+1}\{1,2,\ldots,2n+1\} such that any two consecutive subsets differ in adding or removing a single element. The question whether such a Gray code exists for any n≥1n\geq 1 has been the subject of intensive research during the last 30 years, and has been answered affirmatively only recently [T. M\"utze. Proof of the middle levels conjecture. Proc. London Math. Soc., 112(4):677--713, 2016]. In a follow-up paper [T. M\"utze and J. Nummenpalo. An efficient algorithm for computing a middle levels Gray code. To appear in ACM Transactions on Algorithms, 2018] this existence proof was turned into an algorithm that computes each new set in the Gray code in time O(n)\mathcal{O}(n) on average. In this work we present an algorithm for computing a middle levels Gray code in optimal time and space: each new set is generated in time O(1)\mathcal{O}(1) on average, and the required space is O(n)\mathcal{O}(n)

    A constant-time algorithm for middle levels Gray codes

    Get PDF
    For any integer~n≥1n\geq 1, a \emph{middle levels Gray code} is a cyclic listing of all nn-element and (n+1)(n+1)-element subsets of {1,2,…,2n+1}\{1,2,\ldots,2n+1\} such that any two consecutive sets differ in adding or removing a single element. The question whether such a Gray code exists for any~n≥1n\geq 1 has been the subject of intensive research during the last 30 years, and has been answered affirmatively only recently [T.~M\"utze. Proof of the middle levels conjecture. \textit{Proc. London Math. Soc.}, 112(4):677--713, 2016]. In a follow-up paper [T.~M\"utze and J.~Nummenpalo. An efficient algorithm for computing a middle levels Gray code. \textit{ACM Trans. Algorithms}, 14(2):29~pp., 2018] this existence proof was turned into an algorithm that computes each new set in the Gray code in time~\cO(n) on average. In this work we present an algorithm for computing a middle levels Gray code in optimal time and space: each new set is generated in time~\cO(1), and the required space is~\cO(n)

    Pop & Push: Ordered Tree Iteration in ?(1)-Time

    Get PDF

    Generation, Ranking and Unranking of Ordered Trees with Degree Bounds

    Full text link
    We study the problem of generating, ranking and unranking of unlabeled ordered trees whose nodes have maximum degree of Δ\Delta. This class of trees represents a generalization of chemical trees. A chemical tree is an unlabeled tree in which no node has degree greater than 4. By allowing up to Δ\Delta children for each node of chemical tree instead of 4, we will have a generalization of chemical trees. Here, we introduce a new encoding over an alphabet of size 4 for representing unlabeled ordered trees with maximum degree of Δ\Delta. We use this encoding for generating these trees in A-order with constant average time and O(n) worst case time. Due to the given encoding, with a precomputation of size and time O(n^2) (assuming Δ\Delta is constant), both ranking and unranking algorithms are also designed taking O(n) and O(nlogn) time complexities.Comment: In Proceedings DCM 2015, arXiv:1603.0053

    On the central levels problem

    Get PDF
    The \emph{central levels problem} asserts that the subgraph of the (2m+1)(2m+1)-dimensional hypercube induced by all bitstrings with at least m+1−ℓm+1-\ell many 1s and at most m+ℓm+\ell many 1s, i.e., the vertices in the middle 2ℓ2\ell levels, has a Hamilton cycle for any m≥1m\geq 1 and 1≤ℓ≤m+11\le \ell\le m+1. This problem was raised independently by Buck and Wiedemann, Savage, Gregor and {\v{S}}krekovski, and by Shen and Williams, and it is a common generalization of the well-known \emph{middle levels problem}, namely the case ℓ=1\ell=1, and classical binary Gray codes, namely the case ℓ=m+1\ell=m+1. In this paper we present a general constructive solution of the central levels problem. Our results also imply the existence of optimal cycles through any sequence of ℓ\ell consecutive levels in the nn-dimensional hypercube for any n≥1n\ge 1 and 1≤ℓ≤n+11\le \ell \le n+1. Moreover, extending an earlier construction by Streib and Trotter, we construct a Hamilton cycle through the nn-dimensional hypercube, n≥2n\geq 2, that contains the symmetric chain decomposition constructed by Greene and Kleitman in the 1970s, and we provide a loopless algorithm for computing the corresponding Gray code

    On the Central Levels Problem

    Get PDF
    • …
    corecore