Tree unfold 2026-10-24
Expand a seed by a function returning either no node or a left seed, root label and right seed. Recursively expanding the two seeds produces a binary tree. A finite ascending list split about its midpoint supplies an unfold into a balanced binary tree that is a binary search tree.
Undoing insertion of a new extreme key Created 2026-10-24 Updated 2026-10-31
If a key is smaller than every key of a finite binary search tree , insert and then delete the minimum: the original tree, including its shape, is recovered. The insertion follows the leftmost search route and creates a new minimum leaf; deleting that leaf reverses the same route. The symmetric statement uses a fresh maximum. At a node with root , the bounds on its children therefore let a direct tree fold reconstruct an untouched child from that child's insertion result. This gives a direct fold implementation of insertion without assuming that insertion is injective on arbitrary trees.
Zig-zag step 2026-10-31
When a node and its parent occupy opposite left/right directions, rotate the selected node above its parent and then above its grandparent. These two tree rotations move the selected node two levels upward while preserving the binary search tree ordering.