Binary tree #
Provides binary tree storage for values of any type, with O(lg n) retrieval.
See also Lean.Data.RBTree for red-black trees - this version allows more operations
to be defined and is better suited for in-kernel computation.
We also specialize for BinaryTree Unit, which is a binary tree without any
additional data. We provide the notation a △ b for making a BinaryTree Unit with children
a and b.
References #
https://leanprover-community.github.io/archive/stream/113488-general/topic/tactic.20question.html
A binary tree with values stored in non-leaf nodes.
- nil {α : Type u} : BinaryTree α
- node {α : Type u} (value : α) (left right : BinaryTree α) : BinaryTree α
Instances For
Instances For
Instances For
Alias of BinaryTree.
A binary tree with values stored in non-leaf nodes.
Instances For
Alias of BinaryTree.nil.
Instances For
Do an action for every node of the tree.
Actions are taken in node -> left subtree -> right subtree recursive order.
This function is the traverse function for the Traversable BinaryTree instance.
Instances For
Alias of BinaryTree.traverse.
Instances For
Apply a function to each value in the BinaryTree.
This is the map function for the BinaryTree functor.
Instances For
The number of internal nodes (i.e. not including leaves) of a binary tree
Instances For
Alias of BinaryTree.numNodes.
Instances For
The number of leaves of a binary tree
Instances For
Alias of BinaryTree.numLeaves.
Instances For
The height - length of the longest path from the root - of a binary tree
Instances For
Alias of BinaryTree.height.
Instances For
Alias of BinaryTree.right.
Instances For
Induction principle for BinaryTree Units
Instances For
Alias of BinaryTree.unitRecOn.