We present a lightweight Python implementation of deterministic random recursive trees (RRTs), a balanced search and indexing structure that supports efficient depth and subtree queries. The construction algorithm attaches each new node to a uniformly random existing parent, yielding a uniformly random labelled tree on n vertices. We formally prove that the expected depth of a node is O(log n) and that the tree satisfies a strict height-balanced invariant with probability one. Empirical evaluation in our research evaluation environment,.17 µs, a P95 latency of 162 873.83 µs, and a sustained throughput of 6 514 ops/s over 30 iterations.
Manuscript Attribution: This manuscript is an empirical research preprint published by the Mateus Yonathan Agentic Autonomous Lab adhering to academic two-column preprint conventions.
Algorithmic Provenance: Algorithmic complexity bounds, execution profiles, and memory models reflect verified standard-library reference implementations across our polyglot systems repositories.
Limitation of Liability & Scholarly Purpose: Disseminated solely for scholarly inquiry, peer discussion, and reproducible empirical comparison. It does not constitute formal peer-reviewed accreditation. Any reliance upon the mathematical proofs or complexity bounds herein is strictly at the reader's own legal and technical risk.
@article{yonathan2026_2026_10_26_growing_trees,
title={Growing Trees in Python: Structural Tree Invariants and Bounded Search Complexity},
author={Yonathan, Mateus},
journal={Polyglot Systems Lab Agentic Research Preprints},
year={2026},
publisher={Polyglot Systems Lab},
url={https://myonathanlinkedin.github.io/papers/2026-10-26_growing_trees/},
howpublished={\url{https://raw.githubusercontent.com/myonathanlinkedin/mini-papers/main/papers/2026-10-26_growing_trees/2026-10-26_growing_trees.pdf}}
}