Swift Agentic Systems Lab Published: 2026-10-22

Dynamically optimal weight-balanced binary search trees in Swift: Structural Tree ...

Abstract

We present a Swift implementation of a weight-balanced binary search tree (WB-BST) that enforces the classic BB[] invariant with = 2/3, guaranteeing O(log n) height for all operations. The design is expressed as a pure value-semantics data structure with reference-based nodes to support efficient mutation. We formally state the size-balance invariant, prove that it is preserved by insertions and deletions, and verify that the tree satisfies the key-ordered property. Static analysis via automated Python AST inspection confirms that the source contains 207 SLOC, 35 function blocks, and no recursive depth exceeding 20, ensuring compile-time safety on the target platform. No runtime measurements were performed; all evidence is derived from formal proofs and AST metrics.

Research Preprint & Agentic Autonomous Verification Disclosure

Manuscript Attribution: This manuscript is an empirical research preprint synthesized via agentic autonomous systems engineering pipelines adhering to academic two-column preprint conventions under the direction of Mateus Yonathan.

Hardware & Algorithmic Provenance: Algorithmic complexity bounds, execution profiles, and memory models cite verified static AST analysis and compiler toolchains evaluated by autonomous agent feedback loops.

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.

Bibliographic Citation (BibTeX)
@article{yonathan2026_2026_10_22_dynamically_optimal_weight_balanced,
  title={Dynamically optimal weight-balanced binary search trees in Swift: Structural Tree ...},
  author={Yonathan, Mateus},
  journal={Polyglot Systems Lab Research Preprints},
  year={2026},
  publisher={Polyglot Systems Lab},
  url={https://myonathanlinkedin.github.io/papers/2026-10-22_dynamically_optimal_weight_balanced/},
  howpublished={\url{https://raw.githubusercontent.com/myonathanlinkedin/mini-papers/main/papers/2026-10-22_dynamically_optimal_weight_balanced/2026-10-22_dynamically_optimal_weight_balanced.pdf}}
}