A note on naturally embedded ternary trees

A note on naturally embedded ternary trees

Markus Kuba Markus Kuba
Institut für Diskrete Mathematik und Geometrie
Technische Universität Wien
Wiedner Hauptstr. 8-10/104
1040 Wien, Austria
kuba@dmg.tuwien.ac.at
Abstract.

In this note we consider ternary trees naturally embedded in the plane in a deterministic way such that the root has position zero, or in other words label zero, and the children of a node with position have positions , , and , for all . We derive the generating function of ternary trees where all nodes have labels which are less or equal than , with , which generalizes a result of [9] and [6], and the generating function of ternary trees counted with respect to nodes with label , with . Moreover, we discuss generalizations of the counting problem to several labels at the same time. Furthermore, we use generating functions to study the depths of the external node , or in other words leaf with , where the external nodes of a ternary tree are numbered from the left to the right according to an inorder traveral. The three different types depths – left, right and center – are due to the embedding of the ternary tree in the plane. Finally, we discuss generalizations of the considered enumeration problems to embedded -ary trees.

Key words and phrases:
Ternary trees, Embedded trees, Labelled trees
The author was supported by the Austrian Science Foundation FWF, grant S9608-N13.

1. Introduction

The study of tree families embedded in the plane has recently received a lot of attention. Binary trees, complete binary trees, more generally simply generated tree families, and several different families of planar trees have been considered in a series of papers [4, 5, 13, 8, 3, 2, 11, 12, 7, 15]. It has been shown that embedded trees are closely related to a random measure called ISE (Integrated SuperBrownian Excursion). For example, in the recent paper of Devroye and Janson [7] a conjecture of Bousquet-Mélou and Janson [2] is proven, saying that the vertical profile of a randomly labelled simply generated tree converges in distribution, after suitable normalization, to the density of the ISE. However, enumerative properties of deterministically embedded trees have not been intensively studied, except for binary trees, a particular subclass of ternary trees, and families of plane trees. Motivated by the results of Bousquet-Mélou [3] and Panholzer [15] for embedded binary trees, and the results of Schaeffer and Jacquard [9], and Del Lungo, Del Ristoro and Penaud [6] for a specific subclass of embedded ternary trees, we study several combinatorial properties of ternary trees embedded in the plane in a deterministic manner. We consider the following natural embedding. The root has position zero, or in other words label zero, and the three children of the root have positions , and . More generally, the labels of the children of a node with label are given by , with . A similar embedding of ternary trees has been considered before [9, 6], where the authors studied a particular subclass of embedded ternary trees named skew ternary trees [9], or left ternary trees [6], which are embedded ternary trees with no node having label greater than zero. Using bijections between embedded ternary trees with no label greater than zero and non-separable rooted planar maps with edges they obtained amongst others an explicit result for the number of such trees of size . The aim of this work is to use a generating functions approach to study several parameters in embedded ternary trees: we analyze the distribution of the different types of depths of external nodes in ternary trees, stemming from the embedding of the tree, assuming that the external nodes are enumerated from the left to the right, or in other words with respect to an inorder-traversal. Related parameters have been studied for binary trees in [16, 17, 15]. Moreover, we are interested in the number of embedded ternary trees of size where all internal nodes have label smaller or equal than , with , where we extend the results of [9] and [6] for the special case to arbitrary , and also in the number of embedded ternary of size counted with respect to the number of internal nodes with label , with . We also show how the extend the counting problem to several types of labels considering the nodes with label and the number of nodes with labels in , and also discuss generalizations.

1.1. Plan of the paper

This note is structured as follows. In the next section we recall some well known properties of the family of ternary trees. In Section 3 we discuss the natural embedding of (ternary) trees in the plane, and also provide a formalism for embedded trees. Section 4 is devoted to the study of ternary trees with small label and to ternary trees counted by the number of nodes labelled . In Subsection 4.2 we discuss the enumeration problem of counting the number of nodes with label , and at the same time the number of nodes with labels in . In Section 5 we study the distribution of depths of the -th external node or leaf in ternary trees, with , where the leaves are enumerated from the left to the right. In the final section we discuss some generalizations and open problems, i.e. the extensions of the obtained results to embedded -ary trees.

2. Preliminaries

2.1. The family of ternary trees

The family of ternary trees can be described in a recursive way, which says that a ternary tree is either a leaf (an external node) or an internal node followed by three ordered ternary trees, visually described by the suggestive “equation”

Here is the symbol for an internal node and is the symbol for a leaf or external node. A trivial consequence of this description is the fact that a ternary tree with internal nodes has exactly external nodes; moreover, by taking external nodes into account any node has either outdegree zero or three. Note that throughout this work the notion size of a tree is with respect to the number of internal nodes, a tree of size has internal nodes. We assume that the external nodes of a size ternary tree are numbered from left to right according to a so-called inorder traversal. We start at the root node of a tree. If the tree has internal nodes, we recursively traverse them by going first to the left subtree, then the center subtree, and finally to the right subtree. The external nodes are numbered as visited on the traversal process, see Figure 2. The generating function of the number of ternary trees of size satisfies the equation

(1)

Concerning the series expansion of the generating function it is convenient consider the shifted series . This corresponds to discarding external nodes (the empty tree) in the discription above; we obtain simply generated ternary trees ), defined by the formal equation

(2)

with a node, the cartesian product, and the substituted structure. We refer to [14] for the general definition of simply generated trees. Let denote the number of ternary trees of size , and the number of simply generated ternary trees of size . By the formal description above (2) the counting series satisfies the functional equation

(3)

Due to the Lagrange inversion formula, see e.g. [10], the number of ternary trees of size is given by

(4)

Note that due to the definition the series and are related by . In contrast to the case of binary trees, where the generating function , satisfying , may be expressed in terms of radicals, , for , the case of ternary trees is more complicated due to the third order equation (3); however, there exist appealing closed form expressions of for real values of , i.e.  and ,

which are obtained by Cardano’s method; note that the radius of convergence of and is given by . We obtain by the Lagrange inversion formula the more general formula

Note that since , this immediately implies that for we have

(5)

It turns out that the last representation is valued for all . The result above follows by the binomial theorem, Equation 4 and a variant of the Chu-Vandermonde summation formula.

3. The embedding of ternary trees

Motivated by the results of Bousquet-Mélou [3], and Panholzer [15] for naturally embedded binary trees, and the results of Schaeffer and Jacquard [9], and Del Lungo, Del Ristoro and Penaud [6] for a subclass of ternary trees, we embedd ternary trees in the plane in the following way. The root node has position zero. By definition of ternary trees each internal node with no children has exactly three positions to attach a new node, which are as usual called external nodes or leaves, see Figure 2. We recursively define the embedding of ternary increasing trees as follows: an internal node with label/position has exactly three children, being internal or external, placed at positions , and . Following [3], we call this embedding the natural embedding of ternary trees, because the label a node is its abscissa in the natural integer embedding of the tree. \setcaptionwidth0.3

Figure 1. An embedded size 1 ternary tree with its external nodes.
\setcaptionwidth

0.55

Figure 2. An embedded ternary tree of size 5, its external nodes numbered w. r. t the inorder-traversal.

Equivalent to the embedding, we can think of the edges of a ternary tree being decomposed into three different types, , and . We assume that each internal nodes has exactly one of each edge type pointing away from . Hence, if we assume that an edge of type , with , corresponds to a step , the label of a node in a tree corresponds to the sum over all edges on the unique path from node to the root,

Note that we associate two different kind of labels to external nodes, first the number of the external node according to the inorder-traversal, and second the label of its position according to the natural embedding. This definition readily extends to -ary trees; following the embedding of Bousquet-Mélou [3] of binary trees and the present one stated for ternary trees. It seems natural to assume that for -ary trees each internal node with label has exactly children, internal or external, placed at positions , with , and for -ary trees each internal node with label has exactly children, internal or external, placed at positions , with ; see Figure 3. Equivalently, we have or different types of edges , with either or which correspond to the steps in the obvious way. We point out that the terminology “natural embedding” may be not unique. One could alternatively define the embedding of -ary trees by the increments , which could be considered more natural than , depending on the taste. \setcaptionwidth0.8

Figure 3. Size one embedded quaternary and quinary trees together with their external nodes, i.e. the possible increments and ; an alternative model for embedded quinary trees with increments .

3.1. A formalism for embedded trees

Previously we have stated a definition for embedded ternary trees and more general models of embedded - and -ary trees. However, we have not presented a formalism to actually encode a specific embedded (ternary) tree. Moreover, there exist several different “natural” embeddings of -ary trees. In the following we will give a simple natural way of encoding families of embedded trees, with respect to a set of step vectors. Let denote a given finite non-empty set of step vectors of size , with and , for ; moreover let denote the alphabet . An embedded tree of size one, , is defined as a single point located as the origin with an additional label , denoting the empty word, where the first two entries of the triple encode the points coordinate, and the third entry is the label. An embedded tree of size is defined as a set of labelled points , satisfying two conditions stated below, with denoting a triple , where denote the coordinates of point and denote its label consisting of a word of length over the alphabet , with . We impose two conditions on embedded trees. First, we impose that , and that no other point has a label of length zero. Second, for each labelled point , with , there exists an index with corresponding point and an index , with , such that the point is given by . Equivalently, given an embedded tree of size , we may obtain a size embedded tree by adding the points of the form to , with and .

\setcaptionwidth

0.9

Figure 4. An embedded binary tree of size and its corresponding size path configuration , with , and .

Informally speaking, the stated description of embedded trees corresponds to a reflection followed by a 90 degree rotation of the usual pictures of embedded tree, see Figure 4. Since there may be multiple points at the same coordinate , we use their labels to distinguish between them; more precisely the labels of the points encode how they are reached from the origin with respect to the given set of step vectors . The first condition says nothing else that all trees are rooted at the origin, and the second imposes that each non-root node has a unique parent node. The set of vectors , i.e. the set of vectors of Motzkin paths [1], leads to embedded ternary trees; , i.e. the set of vectors of Dyck paths [1], leads to embedded binary trees as considered in [3]. More generally, the family of embedded -ary and -ary trees, with respect to the natural embedding such that each internal node with label has exactly and children, internal or external, placed at positions , with and , is described using the stepsets , and .

The family of naturally embedded ternary trees with and the family of naturally embedded binary trees with , considered in [3], are symmetric: if then also .

For a given set of step vectors let denote the corresponding family of embedded trees. It is easy to see that the generating function satisfies the equation , where we assume that there exists exactly one embedded tree of size zero. Consequently, with respect to enumeration, embedded trees with can be considered as models of -ary trees.

4. The number of embedded ternary trees with small labels

Let denote the generating function of ternary trees having no label greater than , with , and with the generating function of ternary trees, as specified by (1). The starting point of our considerations is the following system of equations.

Lemma 1.

The series satisfies

(6)
Proof.

First we observe that the infinite system of equations is well defined and complete determines the generating functions . Moreover, following [3] we note that replacing each label by shows that the series is also the generating function of trees rooted at a node with label , and having only non-negative labels for its children. Considering such a tree it has at most three subtrees rooted at , with , which have again only non-negative labels. We have the formal description sketched below in Figure 5, which translates in the stated system of equations and the result follows. ∎

Figure 5. The formal decomposition of embedded ternary trees.

We obtain the following result for the series .

Theorem 1.

Let be the generating function of ternary trees with no label greater than . Then is given by the the following expression

where is defined by (1), i.e. , and the series is defined as the unique formal power series with , satisfying the relations

Moreover, the series has non-negative coefficients and satisfies

with , as defined in (3).

Remark 1.

Let denote the -th Chebyshev polynomial of the second kind, recursively defined by , and for . Following Bouttier et al. [4] we use the well known closed form expression of ,

and observe that can be expressed as the quotient of Chebyshev polynomials of the second kind evaluated at , we have for the expression

An immediate consequence of our result above are explicit formulas for , i.e.  and , stated in the following corollary, which is obtained by elimination of using standard algorithms from the theory of Gröbner bases.

Corollary 1.

The series and , counting the number of embedded ternary trees with no label greater than zero, and one is given by following simple expression.

The coefficients and are for given by the expressions

where denotes the -th Fibonacci number, and the golden ratio.

Remark 2.

The result of the case above has already been obtained in [9, 6] using bijections with maps and 2-stack sortable permutations. We remark that the sequence of coefficients of given by appear as sequence in the Online Encyclopedia of Integer Sequences [18]. The coefficients of given by are not listed there.

Remark 3.

Banderier and Flajolet [1] have studied directed lattice paths in the plane and pointed out the importance of the so-called characteristic polynomial. For so-called simply paths, defined by the set of steps , with and , for , the characteristic polynomial is given by , and the characteristic equation of simple paths is given by . Note that the equation for the series for embedded ternary trees with step set is given by ; for embedded binary trees [3] with step set it is given by . We conjecture that an equation of a similar type , where , is important at least for the analysis of embedded trees with a symmetric step set , where denotes the generating function of the number of embedded trees.

Proof.

In order to proof the result above it is sufficient to check that the series satisfies Equation 6 and the initial condition , which is a simple task. In order to discover the solution we use the method from Bouttier et al. [4], see also Di Francesco [8]. Following [4] we use that fact that for tending to infinity we have . Hence, for tending to infinity one expects that can be written as . We make the Ansatz , with as tends to infinity. We expend Equation 6 with respect to the Ansatz and compare the terms tending at a similar rate to zero as tends to infinity. We get

We assume that is a formal power series such that for a given with , where denotes the radius of convergence of . An Ansatz leads to the so-called characteristic equation

Note that the equation above is identical to the characteristic equation of Motzkin path with being replaced by , where , see [1],. The equation above implies several other relations with respect to ,

Moreover, the equations relating the series and of Theorem 1 are easily derived in a similar manner. Consequently, we define the series as the solution of the equation above with and . We make the improved Ansatz and compare the terms with the same order of magnitude in (6) as tends infinity. Using the fact that we obtain the system of recurrences

which determine uniquely in terms of and rational functions of , with unspecified yet. Although it seems at first glance hopeless to obtain a closed form solution, it is possible to guess a solution with the help of computer algebra software, i.e. the help of Maple, which is easily verified using induction. We obtain the surprisingly simple solution

By our initial assumption we have for small enough. We set , where being small enough and independent of . Consequently, we get after summation the solution

(7)

which satisfies the relation 6 for all , not necessarily larger than zero. In order to see this, we use the notation ; the recurrence relation for , given in Lemma 6, implies that we have to show

which is easily seen to be true for all , with respect to and . Finally, adapting to the initial condition implies that . ∎

4.1. The number of vertices with a given label

Following [3] we are interested in the number of ternary trees of size with a given number of vertices with label . In order to treat this problem we introduce a sequence of bivariate generating functions , where marks the number of internal nodes, and the number of nodes with label , with . Our first observations is already the key point, namely that due to the definition of the embedding of ternary trees, or in other words the symmetry of the step set , we have the symmetry , for all ; moreover we have . The starting point of our considerations is the following lemma.

Lemma 2.

The series satisfies

Proof.

Using the arguments of [3] we observe that the series is also the generating function of trees rooted at a node with label , counted by the number of nodes labelled zero. The formal description sketched Figure 5 translates in the stated system of equations and the result follows. ∎

Theorem 2.

Let be the generating function of ternary trees with counting the number of nodes with label . Then is given by the the following expression

where is defined by (1), i.e. , the series is specified in Theorem 1, and the power series is defined as the unique formal power series with , satisfying the relations

Proof.

We have already seen in the proof of Theorem 2,(7) that the general solution of the set of equations for in Lemma 2 is given by

We have to determine in such a way that the equation for in Lemma 2 is satisfied. Using the general solution stated above and the formulas expression and as functions of we obtain the equation

Now we simply write , and obtain after simple manipulations

We set , and obtain the stated result. ∎

4.2. The number of vertices with given labels

In this section we derive a generalization of our previous result concerning the enumeration of embedded ternary trees of size with respect to the number of nodes with label . The crucial fact in the derivation of the previous result was the symmetry relation , which allowed to conclude the special equation for the case . Hence, when generalizing the counting problem we have to take care to preserve some symmetry in order to set up a system of suitable equations. First, we are interested in counting two statistics at the same time, namely the number of nodes with label , and the number of nodes with label contained in . Let denote the generating function of ternary trees, where the variable counts the number of nodes with label and counts the number of nodes with labels contained in . Since we both types of labels and are counted by the same variable, we have symmetry with respect to the vertical line . More precisely, we obtain the following result.

Lemma 3.

The series satisfies the symmetry relation

for all . Moreover, is determined by the system of equations

The proof is identical to the proof of Lemma 2 and follows the argumentations of [3]. Therefore we omit it. We obtain the following result.

Theorem 3.

The generating function of ternary trees, counting the number of nodes with label and the number of nodes with label in is given by the the following expression

where is defined by (1), i.e. , the series is specified in Theorem 1, and the power series is defined as the unique formal power series with , satisfying the relations

Remark 4.

Note that the series reduces to the series stated in Theorem 3, as it should. Hence, Theorem 3 is a generalization of our previous result. Furthermore, the series , with , counts the number of nodes with label in .

Proof.

We proceed similar to the proof of Theorem 2. The equations for the series and given in Lemma 3 imply the equations

Consequently, we obtain by substituting the equation for into the equation for the result

As in the proof of Theorem 2 we use the fact that the general solution of the set of equations for in Lemma 3 is given by

Simple manipulations leads to the stated result with respect to . ∎

Now discuss a more general counting problem. We are interested in the number of nodes with labels in , counted by the variable , labels in , counted by , up to labels in , counted by . Note that the cases and corresponds to the counting problems treated in Theorems 2,3. We use the vector notation . Let denote the generating function of ternary trees, where the variable counts the number of nodes with label in , for .

Lemma 4.

The series satisfies the symmetry relation for all . Moreover, is determined by the system of equations

The equations above are obtained in the same manner as the equations in the Lemmata 2, 3. Let denote the finite continued fraction in the variables ,

(8)

Consequently, the system of equations stated in Lemma 4 for implies, with respect to the notation above, the equation

(9)

We will use the following lemma.

Lemma 5.

The finite continued fraction , defined in (8), can be written in terms of the family of polynomials in the following way,

Proof.

The finite continued fraction