---
title: Simple Butterfly Trees in BST Analysis
url: https://www.emergentmind.com/topics/simple-butterfly-trees
type: topic
---

# Simple Butterfly Trees in BST Analysis

Searching arXiv for recent papers on simple butterfly trees and closely related butterfly-tree results.
Simple butterfly trees are binary search trees whose insertion order is governed by simple butterfly permutations, namely permutations in the subgroup
$$
B_{n,s}:=S_2\otimes S_2\otimes\cdots\otimes S_2=S_2^{\otimes n}\subset S_{2^n}.
$$
They form a canonical subclass of butterfly trees and of block BSTs, with a dyadic recursive structure motivated by parallel data architectures and closely related to butterfly permutations arising from Gaussian elimination with partial pivoting on simple butterfly matrices. Their recent study is notable for two exact solvable features: an explicit nonasymptotic law for BST height, and an additive-functional representation for the Horton–Strahler number, both of which sharply distinguish the model from classical random BSTs and from more general wreath-product butterfly constructions [2507.04505, 2509.11384, 2410.20952].

## 1. Definition and recursive realization

For a permutation $\pi$ of $\{1,\dots,n\}$, the BST $T(\pi)$ is obtained by inserting keys in the order prescribed by $\pi$, and the height $h(T(\pi))$ is the maximal depth of any node. In the block BST model, an external BST generated by an external permutation $\rho\in S_m$ has each node replaced by an internal BST generated by an internal permutation $\pi_j\in S_n$; the inter-block edges connect the parent’s top-left or top-right edge endpoint to the child’s root. This construction is encoded algebraically by Kronecker or wreath products of permutation matrices, with Kronecker products as the special case of wreath products with identical internal blocks [2507.04505].

Simple butterfly trees specialize this framework to repeated binary Kronecker products. Writing $N:=2^n$, the simple butterfly permutation group is
$$
B_{n,s}=S_2^{\otimes n}\subset S_N,\qquad |B_{n,s}|=2^n=N.
$$
A simple butterfly tree with $N=2^n$ nodes is $T(\pi)$ with $\pi$ uniformly sampled from $B_{n,s}$. Recursively, if $\pi_{n+1}\in S_2$ and $\pi_n\in B_{n,s}$, then
$$
\pi_{n+1}:=\pi_{n+1}\otimes \pi_n\in B_{n+1,s}.
$$
At the tree level, $T(\pi_{n+1})$ is formed by gluing two copies of $T(\pi_n)$ along either the top-right edge if $\pi_{n+1}=12$ or the top-left edge if $\pi_{n+1}=21$. The same recursion can be encoded by a bit string $x=(x_1,\dots,x_n)\in\{0,1\}^n$: at step $j$, one glues a second copy of the level-$(j-1)$ tree to the end of the current top-right edge if $x_j=0$, or to the top-left edge if $x_j=1$. In this formulation, the shape is completely determined by $x$ and exhibits a self-similar, rectangular lattice structure [2509.11384].

This dyadic recursion parallels the stage-by-stage organization of classical butterfly matrices and networks, but the combinatorial object is different. The resulting structure is a BST dictated by binary comparisons during insertion, and the gluing is along extremal paths rather than through a multistage interconnection graph. Algebraically, simple butterfly permutations form an abelian normal subgroup of the nonsimple butterfly group $B_n$, the $2$-Sylow subgroup of $S_{2^n}$ [2507.04505].

## 2. Exact height law

The central structural quantities are the extremal edge lengths. If $\ell(\pi)$ and $r(\pi)$ denote the lengths of the top-left and top-right edges of $T(\pi)$, that is, the number of edges on the unique paths from the root to the nodes $1$ and $n$, then in the simple butterfly model these quantities satisfy a linear recursion together with the height. With $(h_n,\ell_n,r_n)$ denoting the height and extreme-edge lengths of $T(\pi_n)$,
$$
(h_{n+1},\ell_{n+1},r_{n+1})=
(h_n,\ell_n,r_n)+
\begin{cases}
(r_n+1)(1,0,1),& \pi_{n+1}=12,\\
(\ell_n+1)(1,1,0),& \pi_{n+1}=21.
\end{cases}
$$
This implies the identity
$$
h_n=\ell_n+r_n,
$$
which is special to simple butterfly trees [2507.04505].

The same recursion matches permutation-subsequence statistics. For $\pi\in B_{n,s}$,
$$
\mathrm{LIS}(\pi)=\ell(T(\pi))+1,\qquad \mathrm{LDS}(\pi)=r(T(\pi))+1.
$$
Under iterated Kronecker products of $S_2$, $\mathrm{LIS}$ and $\mathrm{LDS}$ either double or remain unchanged at each stage, and they satisfy
$$
\mathrm{LIS}(\pi)\cdot \mathrm{LDS}(\pi)=N,\qquad \log_2 \mathrm{LIS}(\pi)\sim \mathrm{Binom}(n,1/2).
$$
Consequently, if $\pi\sim \mathrm{Unif}(B_{n,s})$ and $h_n^{\operatorname{B}}:=h(T(\pi))$, then
$$
h_n^{\operatorname{B}}=2^{X_n}+2^{n-X_n}-2,\qquad X_n\sim \mathrm{Binom}(n,1/2).
$$
This is an exact nonasymptotic distributional description of the height [2507.04505, 2410.20952].

Several immediate consequences follow. The support is
$$
\{\,2^k+2^{n-k}-2: k=0,1,\dots,n\,\}.
$$
The minimum is
$$
2^{\lfloor n/2\rfloor}+2^{\lceil n/2\rceil}-2=\Theta(\sqrt N),
$$
while the maximum is $N-1$. Small instances already show the discrete binomial structure: for $n=2$, the possible heights are $\{2,3\}$; for $n=3$, they are $\{4,7\}$ with multiplicities induced by $X_3\sim \mathrm{Binom}(3,1/2)$ [2507.04505].

## 3. Asymptotic growth and comparison with random BSTs

The exact law yields
$$
\mathbb{E} h_n^{\operatorname{B}} = 2\left(\frac32\right)^n-2
=2N^\alpha(1+o(1)),
\qquad
\alpha:=\log_2(3/2)\approx 0.58496.
$$
Thus
$$
\mathbb{E} h_N^{\operatorname{B}}=\Theta(N^\alpha),
$$
with exact leading constant $c=2$. The height therefore grows polynomially in the number of nodes $N=2^n$, in sharp contrast to the logarithmic height of uniformly random BSTs [2507.04505].

The logarithmic scale of the random exponent is also explicit:
$$
\frac{\log_2 h_n^{\operatorname{B}}-n/2}{\sqrt n/2}\Rightarrow |Z|,
\qquad Z\sim N(0,1).
$$
Equivalently,
$$
\big[2^{-n/2}h_n^{\operatorname{B}}\big]^{2/\sqrt n}\Rightarrow 2^{|Z|}.
$$
This is a log-normal-type limit in base $2$ driven by the central limit theorem for $X_n$ [2507.04505].

The contrast with classical random BSTs is substantial. Devroye’s theorem states that for $\pi\sim \mathrm{Unif}(S_n)$ and $h_n=h(T(\pi))$,
$$
h_n/\log n\to c^*
$$
in probability and in $L^p$ for $p\ge 1$, where $c^*\approx 4.311$ is the unique solution to
$$
x\log(2e/x)=1,\qquad x\ge 2.
$$
A one-layer block model preserves this logarithmic scaling: if $\pi\sim \mathrm{Unif}(S_n\wr S_m)$ or $\pi\sim \mathrm{Unif}(S_m\otimes S_n)$ with $m$ fixed, then
$$
h_{n,m}/\log(nm)\Rightarrow c^*+h_m,
$$
where $h_m=h(T(\rho))$ for $\rho\sim \mathrm{Unif}(S_m)$. Simple butterfly trees depart from this regime only after iterating the dyadic Kronecker structure across all levels [2507.04505].

The nonsimple butterfly case is intermediate in tractability but not in growth. For wreath-product butterfly trees,
$$
2N^\alpha(1+o(1))\le \mathbb{E}h_N^{\operatorname{B}}\le dN^\beta(1+o(1)),
$$
with
$$
\alpha\approx 0.58496,\qquad \beta\approx 0.913189,\qquad d\approx 2.60958.
$$
The larger upper exponent reflects the more flexible wreath-product structure, which introduces max-operations in the height recursion and stronger growth [2507.04505].

From the algorithmic perspective, BST operations scale as $O(h)$. For simple butterfly trees, typical traversal depth is therefore polynomial rather than logarithmic. This suggests a structural trade-off: the trees inherit deterministic recursive placement and predictable extreme-path gluing, but at the cost of deeper search, insertion, and deletion paths than in classical random BSTs [2507.04505].

## 4. Horton–Strahler number

The Horton–Strahler number (HS), also called the register function, measures branching complexity. With the convention used in the butterfly-tree analysis, leaves have HS value $0$, and for an internal node $v$ with children $v_\ell$ and $v_r$,
$$
\mathrm{HS}(v)=
\begin{cases}
0,& \text{if $v$ is a leaf,}\\[4pt]
\max(\mathrm{HS}(v_\ell),\mathrm{HS}(v_r))+\mathds{1}_{\mathrm{HS}(v_\ell)=\mathrm{HS}(v_r)},& \text{otherwise.}
\end{cases}
$$
Equivalently, $\mathrm{HS}(T)$ is the height of the largest perfect binary subtree embedded in $T$. For any butterfly tree with $N=2^n$ nodes,
$$
\mathrm{HS}(T^B)\le \lfloor \log_4 N\rfloor,
$$
and this upper bound is sharp [2509.11384].

For simple butterfly trees, the HS process can be described directly from the bit string $x=(x_1,\dots,x_n)$. Define increments
$$
X_1=0,\qquad X_j=\mathrm{xor}(x_j,x_{j-1})\cdot (1-X_{j-1}),\qquad j\ge 2.
$$
Then
$$
\mathrm{HS}_N=\sum_{j=1}^n X_j.
$$
In the biased model, where the bits are iid $\mathrm{Bernoulli}(p)$ with $q=1-p$, the triplet
$$
M_j=(x_j,x_{j-1},X_{j-1})\in\{0,1\}^3
$$
is an $8$-state, irreducible and aperiodic Markov chain, and HS is an additive functional of that chain. In the uniform case $p=1/2$, the process reduces to a $2$-state Markov chain for $X_j$ with transition matrix
$$
P=
\begin{bmatrix}
1/2&1/2\\
1&0
\end{bmatrix},
\qquad
\boldsymbol{\pi}^\top=[2/3,\,1/3].
$$
This reduction yields exact means, variances, and fluctuation results [2509.11384].

For uniform simple butterfly trees,
$$
\mathbb{E}[\mathrm{HS}(T^B)]=\log_8 N+O(1),\qquad
\mathrm{Var}(\mathrm{HS}(T^B))=\frac{2}{9}\log_8 N+O(1),
$$
more precisely,
$$
\mathbb{E}[\mathrm{HS}(T^B)]
=\frac n3-\frac29+\frac29\left(-\frac12\right)^n,
$$
and
$$
\mathrm{Var}(\mathrm{HS}(T^B))
=\frac{2}{27}n+\frac{2}{81}
+\frac{4}{27}n\left(-\frac12\right)^n
+\frac{2}{81}\left(-\frac12\right)^n
-\frac{4}{81}\left(\frac14\right)^n.
$$
The weak law of large numbers strengthens to an $L^r$ law of large numbers, and
$$
\frac{\mathrm{HS}(T^B)-\mathbb{E}\mathrm{HS}(T^B)}
{\sqrt{\mathrm{Var}(\mathrm{HS}(T^B))}}
\xrightarrow{d}\mathcal N(0,1),
$$
with a Berry–Esseen-type bound $O(n^{-1/2})$. The paper identifies this as a genuine Gaussian limit law for HS in a nontrivial random tree model, in contrast with classical models where variance remains bounded and periodic fluctuations obstruct a CLT [2509.11384].

The biased case remains explicit. If bits are iid $\mathrm{Bernoulli}(p)$, then
$$
\frac1n\,\mathrm{HS}(T^B)\xrightarrow{\text{a.s.}}\mu_p,
\qquad
\mu_p=\frac{pq}{1-pq},
$$
and
$$
\sqrt n\left(\frac1n\,\mathrm{HS}(T^B)-\mu_p\right)
\xrightarrow{d}\mathcal N(0,\sigma_p^2),
\qquad
\sigma_p^2=\frac{pq(1-3pq-2p^2q^2)}{(1-pq)^3}.
$$
Moreover, the partial-sum process satisfies a Donsker-type invariance principle:
$$
W_n(p,t):=\sqrt n\Big(\frac1n\mathrm{HS}(T^B)(p,t)-t\mu_p\Big)
\xrightarrow{d}\sigma_p B(t).
$$
These results place simple butterfly trees among the rare random-tree models for which HS fluctuations admit a full LLN/CLT/functional CLT package [2509.11384].

The model also admits an $O(n)$, hence $O(\log N)$, algorithm for exact HS evaluation from the compressed bit string. If $y_j=\mathrm{xor}(x_{j+1},x_j)$ and the maximal runs of $1$’s in $y$ have lengths $k_1,\dots,k_\ell$, then
$$
\mathrm{HS}(T^B(x))=\sum_{i=1}^\ell \left\lceil \frac{k_i}{2}\right\rceil.
$$
This is exponentially faster than the standard $O(N)$ HS computation on the explicit tree [2509.11384].

## 5. Origins in butterfly permutations and broader generalizations

Simple butterfly trees belong to a wider theory of butterfly permutations generated from butterfly matrices by Gaussian elimination with partial pivoting. For binary simple scalar butterfly matrices,
$$
B_s(N)=\bigotimes_{j=1}^n R_{\theta_j},
$$
with $\theta_j$ iid uniform on $[0,2\pi)$, GEPP produces
$$
P=\bigotimes_{j=1}^n P_{\theta_j},
$$
where each $P_{\theta_j}$ is either the identity or the transposition $(1\,2)$ depending on whether $|\tan\theta_j|\le 1$ or $>1$. If the angles are iid uniform, then the induced permutation is uniform on the simple butterfly group. This provides a concrete numerical-linear-algebra origin for the model [2410.20952].

The same paper formulates a $p$-ary generalization. For prime $p$,
$$
B_{s,n}^{(p)}=\bigotimes_{j=1}^n \langle \tau_p\rangle,\qquad \tau_p=(1\,2\,\dots\,p),
$$
so $B_{s,n}^{(p)}\cong C_p^n$. The corresponding simple butterfly tree is the rooted $p$-ary tree of depth $n$ in which the action at level $j$ is the same cyclic permutation $\sigma_j\in \langle \tau_p\rangle$ applied uniformly across all $p^{n-j}$ subtrees at that level. If
$$
k-1=(a_1a_2\dots a_n)_p,
$$
then the induced action on leaves is
$$
\sigma(k)=1+\sum_{j=1}^n (\sigma_j(a_j+1)-1)p^{n-j}.
$$
This rooted-tree action makes explicit that the binary simple butterfly model is the $p=2$ case of a broader levelwise cyclic construction [2410.20952].

Within this broader setting, the longest increasing subsequence has an exact multiplicative structure:
$$
L(\sigma_n)\sim \prod_{j=1}^n \max(X_j,p-X_j),
\qquad X_j\sim \mathrm{Unif}(\{1,\dots,p\})\ \text{iid}.
$$
Hence
$$
\mathbb E[L(\sigma_n)]=N^{\alpha_p},
$$
where
$$
p^{\alpha_p}=\frac1p\sum_{j=1}^p \max(j,p-j),
\qquad
\alpha_p=1-O(1/\ln p)=1-o_p(1).
$$
In the binary case $p=2$, $\log_2 L(\sigma_n)\sim \mathrm{Binom}(n,1/2)$ exactly, and
$$
L(\sigma_n)D(\sigma_n)=2^n.
$$
This is precisely the permutation statistic that reappears in the height formula through the identities $\mathrm{LIS}=\ell+1$ and $\mathrm{LDS}=r+1$ [2410.20952].

## 6. Scope, related models, and open problems

The recent literature uses closely related terminology for several distinct objects, and this has generated a potential source of confusion. In the BST literature, simple butterfly trees are the Kronecker-product BSTs associated with $S_2^{\otimes n}$. By contrast, “simple staged trees” are staged trees in algebraic statistics for categorical random vectors, defined by the property that stages and positions coincide; the paper that studies them explicitly notes that the term “simple butterfly trees” does not appear there and treats it only as a possible synonym introduced by query ambiguity [2203.04390]. Likewise, a later paper on “binary butterfly trees” studies full ordered binary trees produced by gluing two plane binary trees along the rightmost leaf and states that it does not introduce a separate subclass called “simple” [2510.18664]. These are different models, with different size notions, probability distributions, and asymptotic questions.

Within the BST and butterfly-permutation framework, the main limitation of current exact theory is the gap between the simple and nonsimple cases. The simple model relies heavily on the abelian Kronecker-product structure and on the rigid coupling between tree geometry and permutation statistics. In the nonsimple wreath-product case, heterogeneous blocks and max-operators in the height recursion obstruct a clean exact law, and only power-law bounds are known for expected height [2507.04505].

Several open problems are explicitly identified. For nonsimple butterfly trees, one goal is an exact expression or sharper asymptotics for $\mathbb E h_n^{\operatorname{B}}$, or a full distributional description analogous to the simple case. For general block BSTs, another problem is to analyze $h_{n,m}$ beyond fixed $m$, especially when both $n$ and $m$ grow. The same work also proposes $p$-ary versions obtained by replacing $S_2$ by cyclic groups of order $p$, and biased models such as Mallows-type perturbations over butterfly/Kronecker-block permutations [2507.04505].

The Horton–Strahler analysis raises a parallel set of questions. For general butterfly trees, the deterministic upper bound
$$
\mathrm{HS}(T^B)\le \lfloor \log_4 N\rfloor
$$
remains, and empirical sampling suggests tight concentration near the upper edge of the support; for $N=1{,}024$ and $10{,}000$ samples, the recorded counts were HS $=3:494$, HS $=4:9{,}040$, and HS $=5:466$, with sample mean $\approx 3.9972$ and sample variance $\approx 0.0960$. The paper highlights as open directions a dynamic description for top-edge profiles, rigorous concentration and variance bounds, and extensions of the LLN/CLT/functional CLT theory beyond the simple subclass [2509.11384].

A broader implication is that simple butterfly trees serve as an exactly analyzable interface between recursive algebraic generation, permutation statistics, and random-tree functionals. The exact height law, the coupling to $\mathrm{LIS}/\mathrm{LDS}$, and the Markov-additive description of Horton–Strahler complexity together make them a reference model for studying how structured insertion orders alter the geometry of binary search trees [2507.04505, 2509.11384, 2410.20952].

Source: https://www.emergentmind.com/topics/simple-butterfly-trees