Protection Number in Plane Trees
Abstract.
The protection number of a plane tree is the minimal distance of the root to a leaf; this definition carries over to an arbitrary node in a plane tree by considering the maximal subtree having this node as a root. We study the the protection number of a uniformly chosen random tree of size and also the protection number of a uniformly chosen node in a uniformly chosen random tree of size . The method is to apply singularity analysis to appropriate generating functions. Additional results are provided as well.
Key words and phrases:
Protected node, protection number, singularity analysis, plane tree1991 Mathematics Subject Classification:
05C05; 05A15, 05A161. Introduction
Cheon and Shapiro [2] started the study of 2protected nodes in trees. A node enjoys this property if its distance to any leaf is at least 2. After this pioneering paper, a large number of papers has been published [13, 6, 1, 10, 5, 12].
In this paper we study the protection number of the root of a (rooted, plane) tree (in the older literature often called ordered tree): It is the minimal distance of the root to any leaf. Further, the protection number of any node is defined by taking the (maximal) subtree that has this node as the root.
Preliminary results on the subject have appeared in the recent paper [3], but we show that, thanks to a rigorous use of methods outlined in the book Analytic Combinatorics [9], we can go much further. We are able to solve a basic recurrence explicitly, which allows us to use singularity analysis of generating functions and getting, at least in principle, as many terms as one wants in the asymptotic expansions of interest. Further, one can derive explicit expressions for the probabilities in question.
Some curious observations related to the constants that appear are also made; they are linked to identities due to Dedekind, Ramanujan and others and are part of the toolkit of the modern analysis of algorithms.
2. Results
In a rooted plane tree , a vertex is said to be protected if its minimum distance from a leaf is at least . The tree is said to be protected if its root is protected.
We denote the maximal such that a vertex is protected by and call it the protection number of . The protection number of the root is called the protection number of the tree, . This means that a tree is protected if and only if .
If a vertex is a leaf, then by definition. Otherwise, if it has children , …, , then
We are interested in the random variables

, the protection number of a uniformly chosen random tree with vertices,

, the protection number of a uniformly chosen vertex in a uniformly chosen random tree with vertices.
We will prove the following results.
Theorem 1.
For , the protection number of a tree with vertices tends to a discrete limit distribution:
Setting
its expectation and variance can be written as
Theorem 2.
For , the protection number of a random vertex of a random tree with vertices tends to a discrete limit distribution:
Setting
its expectation and variance can be written as
3. Number of Protected Trees
In this section, we investigate the auxiliary quantity , the number of protected trees with vertices.
Let denote the set of all rooted plane trees with protection number . Its generating function is denoted by where labels the number of vertices of a tree, i.e.,
Lemma 3.1.
We have
(1) 
and
(2) 
for .
Proof.
It is clear that is the generating function of all rooted plane trees which is wellknown to be given by (1), cf. for instance [9, § I.5.1].
For , the root of a tree is protected if and only if all of its children are protected. Thus a tree is protected if and only if it consists of a root and a nonempty sequence of branches whose roots are protected. This translates into the symbolic equation shown in Figure 1 and thus into the equation
(3) 
for .
Using the abbreviation this leads to
This is reminiscent of continued fractions. We use the Ansatz resulting in the equation
It is sufficient to require
for .
This is a linear recurrence whose characteristic equation has roots and , so its solution has the form . As common factors between and do not matter, we may choose which leads to .
Proposition 3.2.
The probability that a tree is protected is
(4)  
Proof.
We intend to use singularity analysis ([8], [9, Chapter VI]). Let be in some domain at (see [9, Definition VI.1]) with . We have
Inserting this into (2), we get
(5)  
By singularity analysis, we obtain
Singularity analysis and division by the number (the st Catalannumber) of rooted plane trees (this corresponds to setting above) yields (4).
∎
4. Protection Numbers of all Vertices
We now turn to the protection numbers of arbitrary vertices. We fix some and consider the number of protected vertices summed over all trees of size . The corresponding generating function is denoted by
where again labels the number of vertices.
Lemma 4.1.
We have
(6) 
Proof.
In the language of the symbolic method, the generating function corresponds to the class where denotes pointing to a protected vertex, cf. [9, Definition I.14].
A tree and a protected vertex in this tree bijectively correspond to a protected tree whose root is merged with a leaf of another tree , cf. Figure 2.
Thus corresponds bijectively to where denotes pointing at a leaf and the factor on the left hand side denotes one single vertex which compensates the fact that merging the root of one tree with a leaf of the other tree reduces the number of vertices by .
Thus where denotes the generating function of with respect to the number of vertices. Note that the pointing is with respect to leaves, but is a generating function with respect to all vertices.
Let
denote the generating function of where marks the number of vertices and marks the number of leaves. Here, denotes the Narayana number counting the number of trees with vertices and leaves.
Proposition 4.2.
The probability that a random vertex of a random tree with vertices has protection number at least is
Proof.
Dividing by the number of all trees and by the number of vertices yields (4.2). ∎
5. Explicit formula for the number of protected trees
Our goal is to read off the coefficient of in formula (2) in explicit form.
Proposition 5.1.
The number of protected trees with vertices is
6. Functional equations for the constants
Two of the constants satisfy attractive and nontrivial functional equations. This phenomenon is not uncommon in the analysis of algorithms; we point out the paper [11] where it was first observed and the survey [14] which contains many references to earlier papers.
The first example is the constant
with
Proposition 6.1.
We have the functional equation
Since , we have the nearidentity .
Proof.
We compute the Mellin transform of it [7], which exists (at least) in the fundamental strip :
The inversion formula for the Mellin transform gives the original function back (integration is along vertical lines). We shift the line of integration to the left and collect residues:
for
In the remainder of this proof, the relation
(7) 
will be the only property of that we will use.
We now use the duplication formula for the Gamma function and the functional equation for the Riemann zeta function, a substitution and then again a shift of the line of integration.
∎
Our second example relates to a sum that appears within the constant :
with
Proposition 6.2.
We have the functional equation
Since , we have the nearidentity .
References
 [1] Miklós Bóna, protected vertices in binary search trees, Adv. in Appl. Math. 53 (2014), 1–11.
 [2] GiSang Cheon and Louis W. Shapiro, Protected points in ordered trees, Appl. Math. Lett. 21 (2008), no. 5, 516–520.
 [3] Keith Copenhaver, protected vertices in unlabeled rooted plane trees, Graphs Combin. (2017), to appear.
 [4] Nicolaas G. de Bruijn, Donald E. Knuth, and Stephen O. Rice, The average height of planted plane trees, Graph theory and computing, Academic Press, New York, 1972, pp. 15–22.
 [5] Luc Devroye and Svante Janson, Protected nodes and fringe subtrees in some random trees, Electron. Commun. Probab. 19 (2014), no. 6, 10.
 [6] Rosena R. X. Du and Helmut Prodinger, Notes on protected nodes in digital search trees, Appl. Math. Lett. 25 (2012), no. 6, 1025–1028.
 [7] Philippe Flajolet, Xavier Gourdon, and Philippe Dumas, Mellin transforms and asymptotics: Harmonic sums, Theoret. Comput. Sci. 144 (1995), 3–58.
 [8] Philippe Flajolet and Andrew Odlyzko, Singularity analysis of generating functions, SIAM J. Discrete Math. 3 (1990), 216–240.
 [9] Philippe Flajolet and Robert Sedgewick, Analytic combinatorics, Cambridge University Press, Cambridge, 2009.
 [10] Cecilia Holmgren and Svante Janson, Asymptotic distribution of twoprotected nodes in ternary search trees, Electron. J. Probab. 20 (2015), no. 9, 20.
 [11] Peter Kirschenhofer, Helmut Prodinger, and Johannes Schoißengeier, Zur Auswertung gewisser numerischer Reihen mit Hilfe modularer Funktionen, Zahlentheoretische Analysis, II, Lecture Notes in Math., vol. 1262, Springer, Berlin, 1987, pp. 108–110.
 [12] Hosam M. Mahmoud and Mark D. Ward, Asymptotic properties of protected nodes in random recursive trees, J. Appl. Probab. 52 (2015), no. 1, 290–297.
 [13] Toufik Mansour, Protected points in ary trees, Appl. Math. Lett. 24 (2011), no. 4, 478–480.
 [14] Helmut Prodinger, Periodic oscillations in the analysis of algorithms and their cancellations, J. Iran. Stat. Soc. (JIRSS) 3 (2004), 251–270.