Skip to content

BinarySearchTreeParentArray ​

The binary search tree of σ as its parent array: entry v is the value v is inserted under, 0 for the root.

BinarySearchTreeParentArray(Permutation)The binary search tree of σ as its parent array: entry v is the value v is inserted under, 0 for the root.
Typed signatures
TypePackageApplies
(permutation) -> binary_tree_parent_arraycombinatoricsalways

Domain: Combinatorial maps

Details
  • Takes a Permutation and returns a BinaryTreeParentArray — a typed map, so a wrong carrier is a type error rather than a wrong answer.
  • A search tree's values are its in-order labels, so this is the tree's in-order parent array. See bst.ts for why a fold builds it this way.

Examples

Basic #

the one-line word 231231

live ↗
InBinarySearchTreeParentArray(Permutation⁡([2,3,1]))\mathrm{BinarySearchTreeParentArray}({\operatorname{Permutation}}([2, 3, 1]))OutBinaryTreeParentArray⁡([2,0,2]){\operatorname{BinaryTreeParentArray}}([2, 0, 2])
About
Examples1