Skip to content

ParenthesisCodeValue ​

The value, read in binary, of the tree's parenthesis word: each node is ( left ) right, with ( as 1 and ) as 0.

✓ checked against that system · ! checked, with disagreements (hover a chip)FindStatSt000198via BinaryTree✓
ParenthesisCodeValue(tree)The value, read in binary, of the tree's parenthesis word: each node is ( left ) right, with ( as 1 and ) as 0.
Typed signatures
TypePackageApplies
(binary_tree) -> numbercombinatoricsalways

Domain: Tree statistics

Details
  • Defined over BinaryTree as an expression in _x, evaluated by compute-engine — the definition IS the implementation.
  • Takes a BinaryTree 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.
  • The word of a tree with n nodes has 2n digits; the empty tree's is empty, worth 0.

Definition

Epsil, as the implementation runs it.

on BinaryTree, over _x

Apply(
       Function(
                 0 if t in Integers else 2 ^
                                         (2 * (Length(Flatten([t])) - 1) - 1) +
                                         self(self, t[1]) * 2 ^ (2 * (Length(Flatten([t[2]])) -
                                                                      1) + 1) +
                                         self(self, t[2]),
                 self,
                 t,
               ),
       Function(
                 0 if t in Integers else 2 ^
                                         (2 * (Length(Flatten([t])) - 1) - 1) +
                                         self(self, t[1]) * 2 ^ (2 * (Length(Flatten([t[2]])) -
                                                                      1) + 1) +
                                         self(self, t[2]),
                 self,
                 t,
               ),
       _x,
     )

Examples

Basic #

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

live ↗
InParenthesisCodeValue(BinaryTree⁡([[0,0],[[0,0],0]]))\mathrm{ParenthesisCodeValue}({\operatorname{BinaryTree}}(\bigl\lbrack\bigl\lbrack0, 0\bigr\rbrack, \bigl\lbrack\bigl\lbrack0, 0\bigr\rbrack, 0\bigr\rbrack\bigr\rbrack))Out204204
Properties #

FindStat's value for .

live ↗
InCombinatorialStat(BinaryTree⁡(0),ParenthesisCodeValue)\mathrm{CombinatorialStat}({\operatorname{BinaryTree}}(0), \text{ParenthesisCodeValue})Out00

Known value · FindStat St000198

FindStat's value for [.,.]

live ↗
InCombinatorialStat(BinaryTree⁡([0,0]),ParenthesisCodeValue)\mathrm{CombinatorialStat}({\operatorname{BinaryTree}}(\bigl\lbrack0, 0\bigr\rbrack), \text{ParenthesisCodeValue})Out22

Known value · FindStat St000198

FindStat's value for [.,[.,.]]

live ↗
InCombinatorialStat(BinaryTree⁡([0,[0,0]]),ParenthesisCodeValue)\mathrm{CombinatorialStat}({\operatorname{BinaryTree}}(\bigl\lbrack0, \bigl\lbrack0, 0\bigr\rbrack\bigr\rbrack), \text{ParenthesisCodeValue})Out1010

Known value · FindStat St000198

About
Examples4
CrosswalkFindStat