Skip to content

Height ​

The height of a Dyck path, a binary tree or an ordered tree, each counted as FindStat defines it.

✓ checked against that system · ! checked, with disagreements (hover a chip)FindStatSt000050via BinaryTree✓St000013via DyckPath✓St000166via OrderedTree✓
Height(path)The greatest height the Dyck path reaches.
Height(binaryTree)The most nodes on a path from the root, so a single node has height 1 and the empty tree 0 (St000050).
Height(orderedTree)The most edges on a path from the root, so a single vertex has height 0 (St000166).
Typed signatures
TypePackageApplies
(binary_tree | dyck_path | motzkin_path | ordered_tree | schroeder_path) -> numbercombinatoricsalways

Domain: Path and tree statistics

Details
  • Defined over DyckPath as an expression in _x, evaluated by compute-engine — the definition IS the implementation.
  • Takes a DyckPath and 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.
  • On a BinaryTree the height counts nodes: one node has height 1, the empty tree 0.
  • On an OrderedTree the height counts edges: one vertex has height 0.

Definition

Epsil, as the implementation runs it.

on DyckPath, over _x

0 if Length(_x) < 1 else Max(Map(Function(Sum(Map(
                                                   Function(2 * _x[k] - 1, k),
                                                   Range(1, i),
                                                 )), i), Range(1, Length(_x))))

on BinaryTree, over _x

Apply(
       Function(0 if t in Integers else 1 + Max(
                                                 self(self, t[1]),
                                                 self(self, t[2]),
                                               ), self, t),
       Function(0 if t in Integers else 1 + Max(
                                                 self(self, t[1]),
                                                 self(self, t[2]),
                                               ), self, t),
       _x,
     )

on OrderedTree, over _x

Apply(
       Function(0 if Length(t) == 0 else 1 + Fold(
                                                   Function(Max(a, b), a, b),
                                                   0,
                                                   Map(Function(
                                                                 self(self, c),
                                                                 c,
                                                               ), t),
                                                 ), self, t),
       Function(0 if Length(t) == 0 else 1 + Fold(
                                                   Function(Max(a, b), a, b),
                                                   0,
                                                   Map(Function(
                                                                 self(self, c),
                                                                 c,
                                                               ), t),
                                                 ), self, t),
       _x,
     )

Examples

Basic #

the step word UUDDUDUUDDUD

live ↗
InHeight(DyckPath⁡([1,1,0,0,1,0]))\mathrm{Height}({\operatorname{DyckPath}}([1, 1, 0, 0, 1, 0]))Out22

the step word UDUUDDUDUUDD

live ↗
InHeight(DyckPath⁡([1,0,1,1,0,0]))\mathrm{Height}({\operatorname{DyckPath}}([1, 0, 1, 1, 0, 0]))Out22

a single node, counted in nodes

live ↗
InHeight(BinaryTree⁡([0,0]))\mathrm{Height}({\operatorname{BinaryTree}}(\bigl\lbrack0, 0\bigr\rbrack))Out11

the binary tree [[.,.],[[.,.],.]][[.,.],[[.,.],.]]

live ↗
InHeight(BinaryTree⁡([[0,0],[[0,0],0]]))\mathrm{Height}({\operatorname{BinaryTree}}(\bigl\lbrack\bigl\lbrack0, 0\bigr\rbrack, \bigl\lbrack\bigl\lbrack0, 0\bigr\rbrack, 0\bigr\rbrack\bigr\rbrack))Out33

a single vertex, counted in edges

live ↗
InHeight(OrderedTree⁡([]))\mathrm{Height}({\operatorname{OrderedTree}}(\bigl\lbrack\bigr\rbrack))Out00

the ordered tree [[],[[]],[]][[],[[]],[]]

live ↗
InHeight(OrderedTree⁡([[],[[]],[]]))\mathrm{Height}({\operatorname{OrderedTree}}(\bigl\lbrack\bigl\lbrack\bigr\rbrack, \bigl\lbrack\bigl\lbrack\bigr\rbrack\bigr\rbrack, \bigl\lbrack\bigr\rbrack\bigr\rbrack))Out22

the Motzkin path ULUDDLULUDDL

live ↗
InCombinatorialStat(MotzkinPath⁡([1,0,1,−1,−1,0]),Height)\mathrm{CombinatorialStat}({\operatorname{MotzkinPath}}([1, 0, 1, -1, -1, 0]), \text{Height})Out22

the Schroeder path UUDDUDL2UUDDUDL^2, whose double level step does not rise

live ↗
InCombinatorialStat(SchroederPath⁡([1,1,−1,−1,1,−1,2]),Height)\mathrm{CombinatorialStat}({\operatorname{SchroederPath}}([1, 1, -1, -1, 1, -1, 2]), \text{Height})Out22
Properties #

FindStat's value for [1,0]

live ↗
InCombinatorialStat(DyckPath⁡([1,0]),Height)\mathrm{CombinatorialStat}({\operatorname{DyckPath}}([1, 0]), \text{Height})Out11

Known value · FindStat St000013

FindStat's value for [1,0,1,0]

live ↗
InCombinatorialStat(DyckPath⁡([1,0,1,0]),Height)\mathrm{CombinatorialStat}({\operatorname{DyckPath}}([1, 0, 1, 0]), \text{Height})Out11

Known value · FindStat St000013

FindStat's value for [1,1,0,0]

live ↗
InCombinatorialStat(DyckPath⁡([1,1,0,0]),Height)\mathrm{CombinatorialStat}({\operatorname{DyckPath}}([1, 1, 0, 0]), \text{Height})Out22

Known value · FindStat St000013

About
Examples11
CrosswalkFindStat ×3