10 research outputs found

    A constant-time algorithm for middle levels Gray codes

    Get PDF
    For any integer n1n\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 n1n\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~n1n\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~n1n\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)

    2分木の符号化とその応用

    Get PDF
    We show one-one correspondence between all binary trees with n internal nodes and certain bit strings, and the number of the bit strings. We then show the algorithms of ranking and unranking for the bit strings. As one of application problem, algorithms for drawing of all binary trees with n nodes are discussed

    Finding Paths in the Rotation Graph of Binary Trees

    Get PDF
    A binary tree coding scheme is a bijection mapping a set of binary trees to a set of integer tuples called codewords. One problem considered in the literature is that of listing the codewords for n-node binary trees, such that successive codewords represent trees differing by a single rotation, a standard operation for rebalancing binary search trees. Then, the codeword sequence corresponds to an Hamiltonian path in the rotation graph Rn of binary trees, where each node is labelled with an n-node binary tree, and an edge connects two nodes when their trees differ by a single rotation. A related problem is finding a shortest path between two nodes in Rn, which reduces to the problem of transforming one binary tree into another using a minimum number of rotations. Yet a third problem is determining properties of the rotation graph. Our work addresses these three problems. A correspondence between n-node binary trees and triangulations of (n+2)-gons allows labelling nodes of Rn, with triangulations, where adjacent triangulations differ by a single diagonal flip. It has been proven, using properties of triangulations, that Rn is Hamiltonian, and that its diameter is bounded above by 2n-6 for n ≥ 11. In Chapter Three we use triangulations to show that the radius of Rn, is n-1; to characterize the n+2 nodes in the center; to show that Rn is the union of n+2 copies of Rn-1; and to prove that Rn is (n-1)-connected. We also introduce the skeleton graph RSn of Rn, and give additional properties of both graphs. In Chapter Four, we give an algorithm, OzLex, which, for each of many different coding schemes, generates 2n-1 different sequences of codewords for n-node binary trees. We also show that, for every n ≥ 4, all such sequences combined represent 2n Hamiltonian paths in Rn. In Appendix Two, we modify OzLex to create TransOx, an algorithm which generates (n+2)2n sequences of codewords from a single coding scheme, and prove that, for n ≥ 5, the sequences represent (n+2)2n-1 Hamiltonian paths. The distance between extreme nodes in Rn is the diameter of the graph. In Chapter Five, we give properties of extreme nodes in terms of their corresponding triangulations; Appendix One contains additional related information. We present two heuristics, based on flipping diagonals, that find a path between two nodes in Rn: Findpath-1, in O(n log n) time; and FindPath-2, in 0(n2 log n) time. Each computes paths with less than twice the minimum length. We also identify a class of triangulation pairs where Findpath-2 significantly outperforms FindPath-1

    New Combinatorial Properties and Algorithms for AVL Trees

    Get PDF
    In this thesis, new properties of AVL trees and a new partitioning of binary search trees named core partitioning scheme are discussed, this scheme is applied to three binary search trees namely AVL trees, weight-balanced trees, and plain binary search trees. We introduce the core partitioning scheme, which maintains a balanced search tree as a dynamic collection of complete balanced binary trees called cores. Using this technique we achieve the same theoretical efficiency of modern cache-oblivious data structures by using classic data structures such as weight-balanced trees or height balanced trees (e.g. AVL trees). We preserve the original topology and algorithms of the given balanced search tree using a simple post-processing with guaranteed performance to completely rebuild the changed cores (possibly all of them) after each update. Using our core partitioning scheme, we simultaneously achieve good memory allocation, space-efficient representation, and cache-obliviousness. We also apply this scheme to arbitrary binary search trees which can be unbalanced and we produce a new data structure, called Cache-Oblivious General Balanced Tree (COG-tree). Using our scheme, searching a key requires O(log_B n) block transfers and O(log n) comparisons in the external-memory and in the cache-oblivious model. These complexities are theoretically efficient. Interestingly, the core partition for weight-balanced trees and COG-tree can be maintained with amortized O(log_B n) block transfers per update, whereas maintaining the core partition for AVL trees requires more than a poly-logarithmic amortized cost. Studying the properties of these trees also lead us to some other new properties of AVL trees and trees with bounded degree, namely, we present and study gaps in AVL trees and we prove Tarjan et al.'s conjecture on the number of rotations in a sequence of deletions and insertions

    Generating binary trees using rotations

    No full text
    corecore