Linked representations of existing AVL trees #
Matches couples a ghost-labelled linked tree to the existing AVLTree: both its keys
and its encoded cached heights agree, at every node. Heap contents remain governed by
SearchTree.PointerMachine.Represents; no second AVL tree type is introduced.
recomputeHeight_mkNode proves that the concrete nine-instruction height update implements
the cached-height constructor AVLTree.mkNode, preserving the matched children.
It requires consistent child heights but permits an arbitrary old root cache.
Rebuilt is the contract of a routine that rebuilds the subtree under the cursor in place;
the flat and the structured rebalancing programs both establish it.
Same tree shape, scalar keys, and encoded cached heights at every node. The height field must be distinct from key field zero when updating either independently.
A complete AVL match supplies the key-only representation used by search.
A full AVL match preserves the structural height of the underlying binary tree.
A matched root cache is exactly the encoded AVL cached height, with zero for an empty tree.
Nine actual instructions implement mkNode's height recomputation on an existing
linked root. Its two children retain their complete AVL matches; only the root height
field and the declared scratch registers change. Allocation and rebalancing are separate.
The subtree old under the cursor of s has been rebuilt in place as tree, which matches
target: it is represented under the same parent, occupies the same addresses, the cursor is at
its root, register six holds the former root, and the root register and every record outside
it are unchanged.
- rep : SearchTree.PointerMachine.Represents t.heap parent tree
The rebuilt subtree is represented under the same parent.
- matched : Matches encode field tree target
Its keys and height caches match the functional result.
- distinct : SearchTree.PointerMachine.AddressesDistinct tree
Its addresses are distinct.
It occupies the addresses of the old subtree.
The cursor is at its root.
Register six holds the former root.
The root register is unchanged.
No record outside the old subtree changed.