BinarySearchTree
The tree built by inserting σ(1), σ(2), ... into an empty binary search tree.
BinarySearchTree(Permutation)The tree built by inserting σ(1), σ(2), ... into an empty binary search tree.Typed signatures
| Type | Package | Applies |
|---|---|---|
(permutation) -> binary_tree | combinatorics | always |
Details
- Takes a
Permutationand returns aBinaryTree— a typed map, so a wrong carrier is a type error rather than a wrong answer. - Defined as a COMPOSITION, applied right to left: BinaryTree after BinarySearchTreeParentArray. Each step goes through its own declared head, so every intermediate value is a properly constructed carrier.
- The sylvester congruence: two permutations land on the same tree exactly when they agree on which of any pair is inserted first. Built as its parent array (BinarySearchTreeParentArray), then read as a tree.
Examples
See also: BinaryTree, BinarySearchTreeParentArray