PathLength
BinaryTree: The sum of the depths of the nodes, the root's being 0: the internal path length. OrderedTree: The sum of the depths of the vertices, the root's being 0.
✓ checked against that system · ! checked, with disagreements (hover a chip)FindStat
St000398via BinaryTree✓St000400via OrderedTree✓PathLength(tree)BinaryTree: The sum of the depths of the nodes, the root's being 0: the internal path length. OrderedTree: The sum of the depths of the vertices, the root's being 0.Typed signatures
| Type | Package | Applies |
|---|---|---|
(binary_tree | ordered_tree) -> number | combinatorics | always |
Details
- Defined over
BinaryTreeas an expression in_x, evaluated by compute-engine — the definition IS the implementation. - Takes a
BinaryTreeand nothing else — it reads values against their positions, or walks the orbits, so it needs the bijection. Applying it to a bare list is a type error, not a wrong answer. - Defined over
OrderedTreeas an expression in_x, evaluated by compute-engine — the definition IS the implementation. - Takes a
OrderedTreeand nothing else — it reads values against their positions, or walks the orbits, so it needs the bijection. Applying it to a bare list is a type error, not a wrong answer. - Each vertex below a child sits one deeper than in the child's own tree, so the child contributes its vertex count plus its own path length.
Definition
Epsil, as the implementation runs it.
on BinaryTree, over _x
Apply(
Function(0 if t in Integers else level + self(self, t[1], level + 1) +
self(self, t[2], level + 1), self, t, level),
Function(0 if t in Integers else level + self(self, t[1], level + 1) +
self(self, t[2], level + 1), self, t, level),
_x,
0,
)on OrderedTree, over _x
Apply(
Function(
[1, 0] if Length(t) == 0 else Apply(
(r: collection) => [1 +
r[1], r[2]],
Fold(
Function(
[a[1] +
b[1], a[2] +
b[1] +
b[2]],
a,
b,
),
[0, 0],
Map(Function(
self(self, c),
c,
), t),
),
),
self,
t,
),
Function(
[1, 0] if Length(t) == 0 else Apply(
(r: collection) => [1 +
r[1], r[2]],
Fold(
Function(
[a[1] +
b[1], a[2] +
b[1] +
b[2]],
a,
b,
),
[0, 0],
Map(Function(
self(self, c),
c,
), t),
),
),
self,
t,
),
_x,
)[2]Examples
Properties #
About
| Examples | 8 |
|---|---|
| Crosswalk | FindStat ×2 |