Algorithms Seminar 20??{20??,
F. Chyzak (ed.), INRIA, (20??), pp. ??{??.
Available online at the URL
http://algo.inria.fr/seminars/
.
The Tennis Ball Problem
Donatella Merlini
Universita di Firenze
March 19, 2001
Summary by Cyril Banderier
Abstract
Our object is to explore "the s-tennis ball problem" (at each turn s balls are available and
we play with one ball at a time). This is a natural generalization of the case s = 2 considered
by Mallows and Shapiro. We show how this generalization is connected with s-ary trees and
employ the notion of generating trees to obtain a solution expressed in terms of generating
functions. Then, we present a variation in which at each turn we have 4 balls and play
with 2 balls at a time. To solve this problem we use the concepts of Riordan Arrays and
stretched Riordan Arrays, and a generalization of generating trees. This is a joint work with
D. G. Rogers, R. Sprugnoli and M. C. Verri.
1. Introduction
Let 1
be two integer numbers. A tennis player begins a match with 0 ball in the pocket.
At each turn, he is given new balls, that he puts in the pocket, and throws away balls, and so on
until the -th turn. The balls are labelled from 1 to and are served in increasing order. The
balls thrown away form a sequence of labels, we will consider as equivalent two sequences which
are equal once sorted. The tennis ball problem consists in evaluating the following two quantities:
the number n of nonequivalent con gurations after turns and the cumulative sum n (i.e., the
sum { over all the possible con gurations { of the labels of the balls that the player threw away).
t < s
s
t
n
sn
tn
tn
f
n
tn
Turns
=1
=2
=3
=4
n
n
n
n
Turns
=1
=2
=3
=4
n
n
n
n
Arrivals of balls
Balls in the pocket
He receives balls 1 and 2.
1 and 2
He receives balls 3 and 4.
2, 3, and 4
He receives balls 5 and 6.
2, 4, 5, and 6
He receives balls 7 and 8. 4, 5, 6, 7, and 8
Balls thrown away
He throws away ball 1.
He throws away ball 3.
He throws away ball 2.
He throws away ball 6.
sum = 1 + 3 + 2 + 6 = 12
Arrivals of balls Balls in the pocket
Balls thrown away
1 and 2
1 and 2
2
3 and 4
1, 3, and 4
3
5 and 6
1, 4, 5, and 6
4
7 and 8
1, 5, 6, 7, and 8
1
sum = 2 + 3 + 4 + 1 = 10
Figure 1.
Two scenarios for the ( = 2 = 1) tennis ball player.
s
;t
2
The con guration after = 4 turns is (1 2 3 6) for the rst example and (1 2 3 4) for the
second example. In fact, for the (2 1)-case, one has 1 = 2, 2 = 5, 3 = 14, 4 = you guess
what? There is indeed 42 di erent con gurations (after 4 turns), and if one adds all the sums, one
gets 1 = 1 + 2 = 3 2 = (1 + 2) + (1 + 3) + (1 + 4) + (2 + 3) + (2 + 4) = 23 3 = 131 4 = 664, ...
In the next section, it will be shown how the ( 1)-case can be solved in terms of -ary trees (by
symmetry, this also solves the ( ? 1)-case). Then, the last section is dedicated to the (4 2)-case,
that the authors solved with Riordan arrays and a bilabelled generating tree technique.
Turns Arrivals of balls
Balls in the pocket
Balls thrown away
=1
1, 2, 3, 4
1, 2, 3, 4
2, 3,
=2
5, 6, 7, 8
1, 4, 5, 6, 7, 8
1, 7
= 3 9, 10, 11, 12
4, 5, 6, 8, 9, 10, 11, 12
10, 12
= 4 13, 14, 15, 16 4, 5, 6, 8, 9, 11, 13, 14, 15, 16
5, 16
2 + 3 + 1 + 7 + 10 + 12 + 5 + 16 = 56
n
;
;
;
;
;
f
f
f
;
f
;
;
:::
;
;
s;
s
s; s
;
n
n
n
n
Figure 2.
A scenario for the (4 2) tennis ball problem.
;
This is the only case with =
6 1 which is solved. The general ( )-tennis ball problem remains
open.
2. The ( 1)-Tennis Ball Problem
Generating trees are a convenient way to reexpress the problem. Consider an in nite tree T .
The root (labelled 0 and corresponding to the level 0) has children (labelled 1
). Each path
in this tree corresponds to a scenario, thus each node at level has a label which corresponds to
the ball thrown away at turn . As we are counting the sorted con gurations (that is, one does
not care for the order of the balls thrown away), we can without loss of generality suppose that the
labels increase with the depth.
t
s; t
s;
t
;:::;t
n
n
0
1
1
2
3
4
2
3
5
6
4
5
Figure 3.
4
6
5
1
3
6
4
5
4
6
5
1
6
2
2
1
2
1
2
1
3
1
2
2
1
2
3
3
1
2
3
4
The generating tree T for the (2 1)-case and an isomorphic tree Te .
;
(
More generally, the rewriting rule root : (1)
describes the
rule : ( ) 7! (1) ( + ? 2) ( + ? 1)
formation of the tree Te which is isomorphic to the generating tree T of the ( 1)-case: a node with
label at level in the generating tree T becomes a node with label ? + 1 in the tree Te .
Theorem 1. The number n of con gurations for the ( 1) tennis ball problem is the number n+1
of -ary trees with + 1 nodes. One has
k
:::
k
s
:::
k
s
s;
b
i
si
f
s
n
n
T
b
s;
?sn
n
= 1 + ( ? 1)
s
n
and
( )=1+
T z
T
( )s
zT z
:
3
Proof. The problem can be seen as the enumeration of walks (with an unbounded set of jumps
described by the rewriting rule) on the integers, for which the generating function can be made
explicit [1]. Merlini & al. used Riordan array techniques [4].
Theorem 2. The cumulative sum ( i.e., the sum over all the con gurations of the labels of the
thrown balls) is
?sn
n
2 + (s ? 1)n + 1
X
sk
sn
s
(
n
?
k
)
1
n
n?1 =
n?k :
2
(s ? 1)n + 1 ? 2 k=0 n
P
Proof. Consider An = ni=0 `i;n, the sum of all the labels (with multiplicity) at level i in the tree T .
The cumulative sum n satis es
n + 1) T :
n = An ? (sn + 2)(
n+1
2
The generating function for the sequence An is:
zT 0 (z)2 + T 0 (z) :
A(z) = s(s ?21)
T (z)
From these two equations, one gets the almost closed form of the theorem.
Note that the asymptotics of n can easily be deduced from the asymptotics of An .
These theorems are consistent with the fact that the (2; 1)-case leads to Catalan numbers fn =
(2nn) (proven in [2]) and to = 2n2 +5n+4 ?2n+1?22n+1 (as it was found in [3] by hand manipulations
n
n+1
n+2
n
of sums of binomial coecients).
3. The (4; 2)-Tennis Ball Problem
Here again, as one does not care for the order (of the balls thrown away), one can without loss of
generality suppose that any con guration is represented by the smallest equivalent sequence with
respect to the lexicographic order. Thus the con guration (1; 4); (5; 8); (2; 10) is considered to be
the same as the con guration (1; 2); (4; 5); (8; 10).
Let Mm[n] be the number of couples at level n (in the bilabelled generating tree of the (4; 2)-case)
with larger element equal to m, one has the recurrence
Mm[n+1] =
mX
?2
r=2n
(m ? r ? 1)Mr[n] :
De ning fn;k := M4[nn]+1?k gives an in nite lower triangular array:
2
3
4 5 6 7 8 9
n/k 1
0
1
3
2
1
1
2 22 16 10 4 1
3 211 158 105 52 21 6 1
4 2306 1752 1198 644 301 116 36 8 1
P
P
One has the relation fn+1;k+2 = 1
j =0 (j + 1)fn;k+j : The sums fn = k1 fn;k give the sequence
(1; 6; 53; 554; : : : ), the number of con gurations for the (4; 2)-tennis ball problem.
4
It is convenient to transform the above array into a proper Riordan array. A proper Riordan
array is an in nite lower triangular array (D ) 2N which satis es
n;k
d
n+1;k +1
=
1
X
n;k
ad
j
8n; k 2 N :
n;k +j
j =0
P
The generating function A(z ) = a z allows to express d by a Lagrangean like formula
d = [z ]g(z)(zh(z)) where h(z) = A(zh(z)) :
The above array can be embedded in the following array which satis es A(z ) = 1?1 , h(z ) = C (z )
n/k 0 1 2 3 4 5 6 7
0 1
1 0 1
2 1 1 1
3 0 3 2 1
4 6 6 6 3 1
5 0 22 16 10 4 1
6 53 53 53 31 15 5 1
j
j
j
n;k
n
k
n;k
z
(the generating function of Catalan numbers), and g(z ) = 2? ( )+2 (? ) . In particular, the
function g(z ) generates the rst column of this array and corresponds to ?the number
of nonequiv
= ?
3( +2)
2 +4
+3
4 n
?
alent con gurations one wants to enumerate: f = g = ( +3)((2
+2
+2
( +3) 2
+3)
(for even n). The cumulative sum in the tree with root (0; 0) and rewriting rule (k1 ; k2 ) 7!
(0; 0)(0; 1) : : : (k1 + 2; k1 + 2) (thus, a label (k1 ; k2 ) at level n in this tree corresponds to a label
(4n ? k2 ? 1; 4n ? k1 ) in the generating tree of the (4; 2)-case) is then given by
zC z
zC
n
n
=
n
X
X
n
? w
[2n
2h]
r
h=0
[2h]
r
n
=
n
XX
?2 ] represents the number of nodes at level
n
n
n
? w
[2n
r
r
r
n
z
2h]
( +1) 2
n
n
n
=
[2h]
r
h=0
where
n ? h in the subtree starting with (r; );
[2 ]
w represents the total weight that the couples (r; ) have at level h. The Riordan array property
gives (z ) = g(z )C (z ) +2 and w (z ) = g(z )z C (z ) +1 (z C (z )2 + 2r), thus
X?
?
(z) + (?z) w (z) + w (?z) = 12z2 + 284z4 + 5436z6 + 96768z8 + O(z10 ) :
(z ) = 41
[2n
r
h
h
r
r
r
r
r
r
r
r
r
r
r
The next nontrivial open cases are the (5; 2)- and (5; 3)-tennis ball problems. This is related
to the enumeration of 2 and 3-dimensional constrained discrete random walks for which no closed
form (or even recurrence) is known. Articles and slides related to this summary can be found at
Donatella Merlini's webpage http://www.dsi.unifi.it/merlini/Publications.html
[1]
[2]
[3]
[4]
References
Banderier (Cyril), Bousquet-Melou (Mireille), Denise (Alain), Flajolet (Philippe), Gardy (Daniele), and GouyouBeauchamps (Dominique). { Generating functions for generating trees. Discrete Mathematics, 2000. { To appear.
Grimaldi (Ralph P.) and Moser (Joseph G.). { The Catalan numbers and a tennis ball problem. In Proceedings of
the Twenty-eighth Southeastern International Conference on Combinatorics, Graph Theory and Computing (Boca
Raton, FL, 1997), vol. 125, pp. 65{71. { 1997.
Mallows (Colin L.) and Shapiro (Lou). { Balls on the lawn. Journal of Integer Sequences, vol. 2, 1999.
Merlini (D.), Rogers (D. G.), Sprugnoli (R.), and Verri (M. C.). { The tennis ball. Submitted, 2001.