larztree
A binary search tree.
A binary search tree stores values so searching, inserting and finding min/max are fast, and reading them back in order is trivial. A classic, fundamental structure and a great way to understand how ordered data stays efficient - with all four traversals.
larzscript pkg install tree
What you get
- insert / contains / remove
- min / max / height
- inorder (sorted!) + 3 more traversals
- Readable node-based BST
Try it
import "tree" as bst
let t = bst.new()
for x in [5, 3, 8, 1, 4] { bst.insert(t, x) }
print(bst.contains(t, 4))
print(bst.inorder(t))
print(bst.min_(t))
print(bst.height(t))Output
true [1, 3, 4, 5, 8] 1 2
Why it's in the Larz Stack
larztree is a real Larzscript package (larzscript pkg install tree) - money-native, zero dependencies, the same language as the rest of the estate, not a separate Python runtime. It composes with the rest of the Larz Stack and the Larz framework.