120 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)

    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

    Two Reflected Gray Code based orders on some restricted growth sequences

    Full text link
    We consider two order relations: that induced by the m-ary reflected Gray code and a suffix partitioned variation of it. We show that both of them when applied to some sets of restricted growth sequences still yield Gray codes. These sets of sequences are: subexcedant or ascent sequences, restricted growth functions, and staircase words. In each case we give efficient exhaustive generating algorithms and compare the obtained results

    Lattice path matroids: enumerative aspects and Tutte polynomials

    Get PDF
    Fix two lattice paths P and Q from (0,0) to (m,r) that use East and North steps with P never going above Q. We show that the lattice paths that go from (0,0) to (m,r) and that remain in the region bounded by P and Q can be identified with the bases of a particular type of transversal matroid, which we call a lattice path matroid. We consider a variety of enumerative aspects of these matroids and we study three important matroid invariants, namely the Tutte polynomial and, for special types of lattice path matroids, the characteristic polynomial and the beta invariant. In particular, we show that the Tutte polynomial is the generating function for two basic lattice path statistics and we show that certain sequences of lattice path matroids give rise to sequences of Tutte polynomials for which there are relatively simple generating functions. We show that Tutte polynomials of lattice path matroids can be computed in polynomial time. Also, we obtain a new result about lattice paths from an analysis of the beta invariant of certain lattice path matroids.Comment: 28 pages, 11 figure
    • …
    corecore