# Two different 64-leaf trees give identical shape counts for samples of up to 18 leaves

Can we recover the branching pattern of a tree by looking at small groups of its leaves? Suppose we know exactly how often each branching shape occurs among groups of a given size, but the leaves carry no names. Without the leaf names, we lose track of how the groups overlap. The question is how large a group we need before the tally identifies the whole tree.

We construct two different trees on 64 leaves whose counts agree for every group size up to 18 leaves. The first difference appears at 19. The same construction gives a lower bound for every tree size $n\ge4$: to distinguish all trees by exact counts, the number of leaves per group must grow at least as fast as $\sqrt n$.

## Counting shapes in samples of leaves

In a rooted binary tree, each branching point has two children. We consider only the branching shape: exchanging the two children leaves the shape unchanged. To find the shape of a group of $k$ leaves, keep just the paths from the root to those leaves. Remove any point with only one surviving child by joining the path on either side of it. If the root has only one surviving child, move the root down. The resulting tree is called a *card*. The list of counts, one for each possible card shape, is the *$k$-multideck*. Dividing each count by $\binom nk$, the number of groups of $k$ leaves in an $n$-leaf tree, gives the exact probability of seeing that shape when all groups are equally likely.

Clifton and colleagues [1] asked how large a card must be to distinguish every tree on $n$ leaves from every other one. They denoted the smallest such size by $R^{(m)}(n)$. Counting the possible multidecks gave them a logarithmic lower bound, $R^{(m)}(n)\ge (1-o(1))\log n/\log b$ as $n\to\infty$. Here $b\approx2.4832$ is the exponential growth rate of the number of tree shapes, and $o(1)$ tends to zero as $n$ grows. Their upper bound is $R^{(m)}(n)\le n-1$ for $n\ge5$, with $R^{(m)}(4)=4$. When the list records only whether each shape occurs, they obtained a linear lower bound. That argument allows two trees to contain the same shapes in different numbers. Their Problem 5.1 asks for better bounds. By constructing trees whose counts also agree, we raise the logarithmic lower bound for multidecks to a square-root bound.

## Two ways to group four branches

There are two shapes on four leaves. In shape $A$ the root divides the leaves into two pairs; in shape $B$ it divides them one against three. A computer search used small tree shapes tabulated in the appendix of Brosch and Puges [2] to identify the following switch. Take two copies of $A$ and two of $B$. In one tree, join the two $A$ branches on one side of the root and the two $B$ branches on the other. In the other tree, join an $A$ to a $B$ on each side.

![The two rooted trees on 16 leaves, with four-leaf branches ordered A, A, B, B on the left and A, B, A, B on the right.](results/switch.png)

Figure 1. Each $A$ splits its four leaves into two pairs; each $B$ splits them one against three. In the grouped tree (left), take all eight leaves from the two $A$ branches and any one leaf from the other side. The resulting card splits at its root into a leaf and a perfectly balanced eight-leaf tree. There are eight such subsets on the left and none on the right.

We counted the shapes in Figure 1 by examining every subset of leaves in each tree, 131,072 subsets across the pair. All counts agreed through eight leaves. Seven nine-leaf shapes had different counts, including the one in the caption.

## When the counts first differ

Call the smallest card size at which two trees give different counts their *separation*. Two different trees with the same number of leaves have separation at least four: at each of sizes one, two and three there is only one possible shape. Write $A*B$ for the tree made by joining $A$ and $B$ under a new root. The switch in Figure 1 uses the same pair of shapes twice. When we use two different pairs, the new separation is the sum of the two separations plus one.

*Lemma (branch exchange).* Suppose $A,B$ have $a$ leaves each and separation $d\ge2$, and $C,D$ have $b$ leaves each and separation $e\ge2$. Then the trees
\[
 (A*C)*(B*D) \qquad\text{and}\qquad (A*D)*(B*C)
\]
have $2(a+b)$ leaves each and separation exactly $d+e+1$.

*Proof.* For a tree $T$, write $F(T)$ for its counts at all sizes, expressed as a sum in which each card shape is multiplied by its count. Call the number of leaves in a shape its *degree*. Include the empty card, written $1$, once. To graft two sums, graft each shape in the first to each shape in the second and multiply their counts. Keep the parentheses: the order in which we join branches can change the tree. Grafting an empty card to any shape $S$ leaves $S$ unchanged, so $1*S=S$, including when $S=1$. Choosing a subset of leaves in $S*T$ amounts to choosing a subset in each branch independently. If one subset is empty, the new root disappears. The graft of the two sums therefore counts every subset with its correct shape: $F(S*T)=F(S)*F(T)$.

Write $P=F(B)$ and $Q=F(D)$, and let $X=F(A)-P$ and $Y=F(C)-Q$ be the two differences. They start in degrees $d$ and $e$. Substitute $P+X$ for $F(A)$ and $Q+Y$ for $F(C)$ in the card sums for the two trees in the lemma. On subtraction, every term missing either $X$ or $Y$ cancels. What remains is
\[
 (X*Y)*(P*Q) - (X*Q)*(P*Y).
\]
When both $P$ and $Q$ contribute only the empty card, each term reduces to $X*Y$. Thus even $d+e$ leaves give identical counts. A surviving term requires at least one more leaf.

One more leaf also suffices. Let $L$ be a leaf, and let $U$ be the degree-$d$ part of $X$: for each $d$-leaf shape its coefficient is the count in $A$ minus the count in $B$. Define $V$ similarly as the degree-$e$ part of $Y$. Since $P$ starts with $1+aL$ and $Q$ with $1+bL$, the difference at degree $d+e+1$ is
\[
 (a+b)L*(U*V) - b(U*L)*V - aU*(L*V).
\]
Only the first term has a single leaf as one of its root branches. The other two split at the root into sizes $(d+1,e)$ and $(d,e+1)$, all greater than one. To see that $U*V$ is nonzero despite its signed coefficients, assign a distinct variable to each nonempty shape. Replace each shape in $U$ and $V$ by its variable, keeping its signed count. This gives two nonzero polynomials, so their ordinary product is nonzero. Each product of two variables stands for a distinct graft: cutting the graft at the root recovers exactly that unordered pair of shapes. Attaching $L$ to these grafts also preserves their distinct shapes. Hence at least one card with a leaf at the root has a different count, proving the separation formula.

## The bound at every tree size

Using the same pair twice, as in Figure 1, quadruples the number of leaves but more than doubles the separation. Starting from the two four-leaf shapes (separation four), after $h$ rounds the trees each have $4^{h+1}$ leaves and separation $5\cdot2^h-1$. To cover the sizes between rounds, we combine pairs of different sizes and then add leaves as needed.

To combine $\ell$ starting pairs, draw a branching diagram with one starting pair at each tip. Work from the tips toward the root. At each fork, use the switch to turn the two child pairs into one new pair. Give each pair a score equal to its separation plus one. By the lemma, the score at a fork is the sum of the scores of its children. Each starting pair has score five, so the final separation is $5\ell-1$. A starting pair at depth $j$ (that many forks from the tip to the root) contributes $4\cdot2^j$ leaves to each final tree: every fork on its path to the root doubles its contribution.

Let $p$ be the largest power of two at most $\ell$. Start with $p$ tips all at the same depth, then split $\ell-p$ tips once. Of the resulting tips, $2p-\ell$ contribute $4p$ leaves each and $2(\ell-p)$ contribute $8p$ each. The total is
\[
 N(\ell)=4p(3\ell-2p)\le \tfrac92\ell^2,
\]
where the inequality follows from $(3\ell-4p)^2\ge0$. For any $n\ge4$, choose the largest $\ell$ with $N(\ell)\le n$. If $N(\ell)<n$, graft the same tree of $n-N(\ell)$ leaves onto each of the two trees. Grafting their difference in card sums to the empty card preserves its first nonzero degree; grafting it to any nonempty card raises the degree. The added tree has exactly one empty card, so the separation stays the same. Since $n<N(\ell+1)\le\tfrac92(\ell+1)^2$, we obtain
\[
 R^{(m)}(n)\ \ge\ 5\ell-1\ >\ \frac{5\sqrt2}{3}\sqrt n-6 .
\]
The first inequality holds because the constructed trees agree at *every* card size below their separation.

## Independent counts

We checked the formula by counting occurrences of each card shape separately. The checks used pairs of the same size, pairs of different sizes and a pair with an extra leaf grafted to each tree. To list all possible target shapes through 19 leaves, we joined every unordered pair of smaller shapes whose leaf counts added to the required size.

For a target of at least two leaves, the selected leaves either all lie in one branch of the tree being checked or occupy both branches. For the first case we added the occurrence counts within the two branches. For the second, we assigned one branch of the target to each branch of the tree and multiplied the counts for those assignments. We also counted the reverse assignment if the target branches had different shapes. For a single-leaf target the count was the number of leaves in the tree. This calculation uses only nonnegative integers and does not rely on the cancellations in the proof. At each size $k$ the counts summed to $\binom nk$. The first difference occurred at the predicted size in every case.

| Construction | Leaves per tree | First differing card size | Shapes with different counts at that size |
|---|---:|---:|---:|
| Starting pair | 4 | 4 | 2 |
| Switch on two starting pairs | 16 | 9 | 7 |
| Switch on 4- and 16-leaf pairs | 40 | 14 | 42 |
| Same 40-leaf pair with a leaf grafted to each tree | 41 | 14 | 42 |
| Switch on two 16-leaf pairs | 64 | 19 | 77 |

These examples give a worst-case limit for trees with unnamed leaves, even when every count is known exactly. The limit concerns the number of leaves per sample, not how many random samples it takes to estimate a frequency. The lower bound grows as the square root of tree size; the known upper bound grows linearly. Whether samples of order $\sqrt n$ suffice to distinguish all such trees remains open.

## References

1. A. Clifton, É. Czabarka, A. Dossou-Olory, K. Liu, S. Loeb, U. Okur, L. Székely and K. Wicke. [Decks of rooted binary trees](https://doi.org/10.1016/j.ejc.2024.104076). *European Journal of Combinatorics*. See [Theorem 3.8, Corollary 3.13 and Problem 5.1](https://arxiv.org/abs/2311.02255).
2. D. Brosch and D. Puges. [Getting to the root of the problem: sums of squares for limits of trees](https://doi.org/10.1007/s10107-025-02305-1). *Mathematical Programming*. Tree shapes from the topology column of the [version 3 source appendix](https://arxiv.org/src/2404.12838v3).
