The original subtree selected by a binary-search-tree access #
searchFocus is ordinary mathematical BST search. It returns the original
subtree rooted at the matching node, or at the last node visited on an
unsuccessful search. It does not rotate a tree, model memory or assign costs.
The splay implementation's correctness theorem can therefore specify its new
root without maintaining a second executable splay algorithm.
Node labels are stable natural-number IDs; keys gives their mathematical keys.
Orderedness is exactly mathlib's List.Pairwise on the inorder key sequence.
The original subtree at the matching or last visited node of ordinary BST search.
Equations
- One or more equations did not get rendered due to their size.
- Complexity.Language.Examples.Splay.searchFocus keys query Tree.nil = Tree.nil
Instances For
The number of edges to nonempty children traversed by ordinary BST search. This is a structural path length, not a price assigned to executable operations.
Equations
Instances For
An original subtree, reached by zero or more child edges without any rotation.
- refl (tree : Tree ℕ) : IsSubtree tree tree
- left {focus left right : Tree ℕ} {root : ℕ} (sub : IsSubtree focus left) : IsSubtree focus (Tree.node root left right)
- right {focus left right : Tree ℕ} {root : ℕ} (sub : IsSubtree focus right) : IsSubtree focus (Tree.node root left right)
Instances For
At the last visited node, the key matches or the requested child is empty.
Equations
Instances For
Ordinary search selects an original subtree and stops at precisely a terminal node.
On an ordered tree, any existing query is the key at the selected root.
An unsuccessful search ends at a node whose requested child is empty.