Counting Palindromes According to r-runs of Ones Using Generating Functions

Similar documents
Counting Palindromes According to r-runs of Ones Using Generating Functions

Counting Palindromic Binary Strings Without r-runs of Ones

Enumerating Binary Strings

Almost all trees have an even number of independent sets

Growing and Destroying Catalan Stanley Trees

ROSENA R.X. DU AND HELMUT PRODINGER. Dedicated to Philippe Flajolet ( )

New Multiple Harmonic Sum Identities

Additive irreducibles in α-expansions

Theory of Computation 1 Sets and Regular Expressions

Hamming Weight of the Non-Adjacent-Form under Various Input Statistics. Clemens Heuberger and Helmut Prodinger

7 Asymptotics for Meromorphic Functions

The Number of Inversions in Permutations: A Saddle Point Approach

arxiv: v1 [math.co] 13 Jul 2017

ABSTRACT 1. INTRODUCTION

COMPOSITIONS WITH A FIXED NUMBER OF INVERSIONS

On the parity of the Wiener index

The distribution of run lengths in integer compositions

On the Sequence A and Its Combinatorial Interpretations

Counting set systems by weight

arxiv: v1 [math.co] 1 Aug 2018

On the Density of Languages Representing Finite Set Partitions 1

k-protected VERTICES IN BINARY SEARCH TREES

COMPLEMENTARY FAMILIES OF THE FIBONACCI-LUCAS RELATIONS. Ivica Martinjak Faculty of Science, University of Zagreb, Zagreb, Croatia

Convoluted Convolved Fibonacci Numbers

Compositions, Bijections, and Enumerations

Also available at ISSN (printed edn.), ISSN (electronic edn.)

ON THE COEFFICIENTS OF AN ASYMPTOTIC EXPANSION RELATED TO SOMOS QUADRATIC RECURRENCE CONSTANT

Factorizations of the Fibonacci Infinite Word

An Application of Catalan Numbers on Cayley Tree of Order 2: Single Polygon Counting

Generating Functions

Computational Models Lecture 2 1

The number of inversions in permutations: A saddle point approach

Graphs with maximal Hosoya index and minimal Merrifield-Simmons index

CSCI 2200 Foundations of Computer Science Spring 2018 Quiz 3 (May 2, 2018) SOLUTIONS

Toufik Mansour 1. Department of Mathematics, Chalmers University of Technology, S Göteborg, Sweden

Section 4.1: Sequences and Series

1 Computational Problems

MINIMAL EXPANSIONS IN REDUNDANT NUMBER SYSTEMS: FIBONACCI BASES AND GREEDY ALGORITHMS. 1. Introduction. ε j G j, n = j 0

Fooling Sets and. Lecture 5

Asymptotics of generating the symmetric and alternating groups

Improving the KMP Algorithm by Using Properties of Fibonacci String

A REFINED ENUMERATION OF p-ary LABELED TREES

Maximizing the number of independent subsets over trees with maximum degree 3. Clemens Heuberger and Stephan G. Wagner

Recursive Definitions

Summations in Bernoulli s Triangles via Generating Functions

1 Alphabets and Languages

Counting permutations by cyclic peaks and valleys

A class of trees and its Wiener index.

Chapter 0 Introduction. Fourth Academic Year/ Elective Course Electrical Engineering Department College of Engineering University of Salahaddin

Graphs with few total dominating sets

5. Analytic Combinatorics

ASYMPTOTIC ENUMERATION OF PERMUTATIONS AVOIDING GENERALIZED PATTERNS

Computational Models Lecture 2 1

Sums of Squares and Products of Jacobsthal Numbers

ON POLYNOMIAL REPRESENTATION FUNCTIONS FOR MULTILINEAR FORMS. 1. Introduction

Palindromic complexity of infinite words associated with simple Parry numbers

Sorting suffixes of two-pattern strings

FIBONACCI NUMBERS AND DECIMATION OF BINARY SEQUENCES

CSC173 Workshop: 13 Sept. Notes

CSCE 222 Discrete Structures for Computing. Dr. Hyunyoung Lee

A GENERALIZATION OF A FILBERT MATRIX WITH 3 ADDITIONAL PARAMETERS

SELF-AVOIDING WALKS AND FIBONACCI NUMBERS. Arthur T. Benjamin Dept. of Mathematics, Harvey Mudd College, Claremont, CA

Context-free grammars and languages

ON THE DECIMAL EXPANSION OF ALGEBRAIC NUMBERS

Results on Transforming NFA into DFCA

On the number of F -matchings in a tree

Forty years of tree enumeration

Combinatorial Interpretations of a Generalization of the Genocchi Numbers

Notes for Lecture Notes 2

CSE 105 Homework 1 Due: Monday October 9, Instructions. should be on each page of the submission.

are the q-versions of n, n! and . The falling factorial is (x) k = x(x 1)(x 2)... (x k + 1).

The Gaussian coefficient revisited

1 Introduction 1. 5 Rooted Partitions and Euler s Theorem Vocabulary of Rooted Partitions Rooted Partition Theorems...

Words with the Smallest Number of Closed Factors

SIMPLE ALGORITHM FOR SORTING THE FIBONACCI STRING ROTATIONS

languages by semifilter-congruences

ON HIGHLY PALINDROMIC WORDS

CS500 Homework #2 Solutions

CS 121, Section 2. Week of September 16, 2013

AVOIDING PERMUTATIONS AND THE NARAYANA NUMBERS

CS 455/555: Mathematical preliminaries

(NB. Pages are intended for those who need repeated study in formal languages) Length of a string. Formal languages. Substrings: Prefix, suffix.

Quantum Field theories, Quivers and Word combinatorics

A Recursive Relation for Weighted Motzkin Sequences

Concatenation. The concatenation of two languages L 1 and L 2

1. Induction on Strings

C-COLOR COMPOSITIONS AND PALINDROMES

A BIJECTION BETWEEN WELL-LABELLED POSITIVE PATHS AND MATCHINGS

On the number of matchings of a tree.

Introduction to Techniques for Counting

Binomial Coefficient Identities/Complements

Games derived from a generalized Thue-Morse word

Recurrence Relations and Recursion: MATH 180

Fall 2017 Test II review problems

Two-stage allocations and the double Q-function

On the number of prefix and border tables

THE ALTERNATING GREEDY EXPANSION AND APPLICATIONS TO COMPUTING DIGIT EXPANSIONS FROM LEFT-TO-RIGHT IN CRYPTOGRAPHY

CSCC63 Worksheet Turing Machines

ASYMMETRIC GENERALIZATIONS OF THE FILBERT MATRIX AND VARIANTS. Emrah Kılıç and Helmut Prodinger

Words restricted by patterns with at most 2 distinct letters

Transcription:

3 47 6 3 Journal of Integer Sequences, Vol. 7 (04), Article 4.6. Counting Palindromes According to r-runs of Ones Using Generating Functions Helmut Prodinger Department of Mathematics Stellenbosch University 760 Stellenbosch South Africa hproding@sun.ac.za Abstract We derive generating functions for the enumeration of all palindromic binary strings of length n having only runs of s of length r. We provide asymptotic expressions for fixed r and n. Eventually, r is treated as a random variable and an asymptotic equivalent for the largest run of s in binary palindromes is derived. Enumeration In the recent paper [3 the interest was in words over the alphabet {0,} which are palindromes and have runs of s of bounded length. We firmly believe that generating functions are the most appropriate tool here, and since they were not used in [3, we present this natural approach and show as well how one can deal with the case that the maximal -run length is treated as a random variable. It is worthwhile to note that all our methods can be found in [. Let us start with palindromes of even length; they are given as ww R, with a reversed copy of w attached to w. In unrestricted words, the following factorization is appropriate: (0+) = ( 0). Here, we used the -operation, common in the study of formal languages, so L denotes all words that can be formed from concatenating words taken from L in all possible ways. In

[, the notation Seq(L) is mostly used, describing all Sequences (aka words), formed from L. Now, the mentioned factorization is a very common one for binary words. Each word is (uniquely) decomposed according to each appearence of the letter 0; between them, there are runs (possibly empty) of the letter. If a word has s letters 0, then there are s+ such runs of s. In terms of generating functions, since the transition A A means f, f the factorization reads as z = z z. z This factorization can immediately be generalized to the instance when the -runs should not exceed the parameter r. Then we first consider the set of restricted runs which translates into r = {ε,,,..., r }, +z + +z r = zr+ z. Then we get the formal expression ( r 0) r, which translates into r z( zr+ ) z z r+ z = zr+ z +z r+. Now, going to palindromes of even length, the last group of ones must be bounded by. So a syntactic description of palindromes of even length with bounded -runs is ( r 0) r ; this describes the first half of the word only. From this we go immediately to generating functions, by replacing both letters by a variable z. In this way, we count half of the length of the palindromes of even length. If one wants the full length, one must replace z by z. So we get z r + = z r + z zr+ z z +zr+. () z One can read off the coefficient of z n in the power series expansion of this expression, which leads to a clumsy expression: Set a n,r = [z n z +z r, then a n,r a n,r +a n r,r = 0,

and initial conditions a n,r = n for n < r. Then the number of palindromes of even length n with all -runs r is given by [z n z r + z +z r+ = a n,r+ a n r,r+. We can alternatively express the coefficients in () using the higher order Fibonacci numbers, as it was done in [3: Consider U n,r = U n,r + +U n r,r for n r, with initial values U 0,r = = U r,r = 0, U r,r =. Then U n,r z n = n 0 z r (z r + +z) = zr z zr z = zr ( z) z +z r+. Further, or Consequently (U 0,r + +U n,r )z n = n 0 z r z +z r+, n+r U k,r+ = [z n z +z r+. [z n z r + z +z = r+ [zn z +z n+r = U k,r+ = n+r k=n r +r U k,r+. r [zn r+ n r +r U k,r+ z +z r+ This is the expression given in [3 once one changes the index of summation. Note that r r = r. Now we move to palindromes of odd length with middle letter : ww R. Then w is described by ( r 0) r. In this way, the last group of ones plus the middle plus the first group of ones of the reversed word is still r as it should. The corresponding generating function is z r + z +z r+ 3

and the coefficient of z n (counting palindromes of odd length n+ with middle letter ) is a n,r+ a n r,r+. Again, we can alternatively express the corresponding number by higher order Fibonacci numbers: z r [z n + z +z = r+ [zn [zn z +zr+ n+r = U k,r+ = n+r n r +r k=n r +r U k,r+. r U k,r+ z +z r+ Note that r r = r +. Finally we move to palindromes of odd length with middle letter 0: w0w R. Then we have ( r 0) r, since the middle 0 interrupts the last run of ones of the first group. The corresponding generating function is z r+ z +z r+, where again the coefficient of z n refers to a palindrome of length n+ with middle 0. Explicitly we get z r+ [z n z +z = a r+ n,r+ a n r,r+. In terms of higher order Fibonacci numbers, this reads Asymptotics [z n z r+ z +z = r+ [zn z +z r+ [zn r z +z r+ n+r n = U k,r+ n+r = U k,r+. k=n U k,r+ We refer to the paper [ which might be the first to consider asymptotics for words of restricted runs. The recent paper [4 has many examples of this type. Here, we only consider the key steps and refer for error bounds to the cited literature. 4

One has to study the dominant zero of the denominator, denoted by ρ, which is close to when r gets large (no restriction). From ρ+ρ r+ = 0 we infer ρ = + ρr+ + r+3. This procedure is called bootstrapping. We also need the constant A in z +z r+ A z/ρ as z ρ, which we get by L Hopital s rule as /ρ A = +(r +)z r+ = z=ρ /ρ +(r+)ρ = r+ ρ (r+)(ρ ). So we get the following asymptotic formulæ, valid for n and fixed r: z r + [z n ( ρ + )Aρ n, z +zr+ z r [z n + r ( ρ + )Aρ n, z +zr+ z r+ [z n z +z r+ ( ρr+ )Aρ n. And now we turn to the instance where r is a random variable X, and compute, as a showcase, the expected value, so we answer the question about the average value of the longest -run in palindromes, in the 3 respective models. As mentioned, this was basically done already by Knuth. When r gets large, the constant A may be replaced by, terms of the form ρ r may be dropped, and in ρ n, it is enough to use the approximation ρ n n ( r ) n n exp( n/ r+ ). Furthermore, to get a probability distribution, we have to divide by n, which is the number of binary words of length n. So the probability that the parameter X is r is in all 3 instances approximated by exp( n/ r+ ). For an expected value, one has to compute [ exp( n/ r+ ). r 0 r 5

This evaluation can be found in many texts [,, 4; it is done with the Mellin transform, and the result is log n+ γ log 3 ( kπi ) Γ e kπi log n. log log Observe that the series in this expression represents a periodic function with small amplitude. Asymptotically, thus, palindromes with middle letter 0 resp. resp. no middle letter all lead to the same result. k 0 References [ P. Flajolet and R. Sedgewick. Analytic Combinatorics. Cambridge University Press, Cambridge, 009. [ D. E. Knuth. The average time for carry propagation. Indag. Math. 40 (978), 38 4. [3 M. A. Nyblom. Counting palindromic binary strings without r-runs of ones. J. Integer Sequences 6 (03), Article 3.8.7. [4 H. Prodinger and S. Wagner. Bootstrapping and double-exponential limit laws. Submitted. 00 Mathematics Subject Classification: Primary B39; Secondary 05A5. Keywords: binary string, generating function, r-run of ones, asymptotics. Received October 9 03; revised version received April 6 04; April 5 04. Published in Journal of Integer Sequences, April 5 04. Return to Journal of Integer Sequences home page. 6