Skip to content

DistinctSubtrees ​

BinaryTree: The number of different nonempty subtrees. OrderedTree: The number of different subtrees.

✓ checked against that system · ! checked, with disagreements (hover a chip)FindStatSt001554via BinaryTree✓St000521via OrderedTree✓
DistinctSubtrees(tree)BinaryTree: The number of different nonempty subtrees. OrderedTree: The number of different subtrees.
Typed signatures
TypePackageApplies
(binary_tree | ordered_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.
  • Defined over OrderedTree as an expression in _x, evaluated by compute-engine — the definition IS the implementation.
  • Takes a OrderedTree 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.

Definition

Epsil, as the implementation runs it.

on BinaryTree, over _x

Length(Unique(Apply(
                     Function([] if t in Integers else Join(
                                                             [t],
                                                             self(self, t[1]),
                                                             self(self, t[2]),
                                                           ), self, t),
                     Function([] if t in Integers else Join(
                                                             [t],
                                                             self(self, t[1]),
                                                             self(self, t[2]),
                                                           ), self, t),
                     _x,
                   )))

on OrderedTree, over _x

Length(Unique(Apply(
                     Function([t] if Length(t) == 0 else Join(
                                                               [t],
                                                               Fold(
                                                                     Function(
                                                                               Join(a, b),
                                                                               a,
                                                                               b,
                                                                             ),
                                                                     [],
                                                                     Map(Function(
                                                                                   self(self, c),
                                                                                   c,
                                                                                 ), t),
                                                                   ),
                                                             ), self, t),
                     Function([t] if Length(t) == 0 else Join(
                                                               [t],
                                                               Fold(
                                                                     Function(
                                                                               Join(a, b),
                                                                               a,
                                                                               b,
                                                                             ),
                                                                     [],
                                                                     Map(Function(
                                                                                   self(self, c),
                                                                                   c,
                                                                                 ), t),
                                                                   ),
                                                             ), self, t),
                     _x,
                   )))

Examples

Basic #

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

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

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

live ↗
InDistinctSubtrees(OrderedTree⁡([[],[[]],[]]))\mathrm{DistinctSubtrees}({\operatorname{OrderedTree}}(\bigl\lbrack\bigl\lbrack\bigr\rbrack, \bigl\lbrack\bigl\lbrack\bigr\rbrack\bigr\rbrack, \bigl\lbrack\bigr\rbrack\bigr\rbrack))Out33
Properties #

FindStat's value for [.,.]

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

Known value · FindStat St001554

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

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

Known value · FindStat St001554

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

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

Known value · FindStat St001554

FindStat's value for [[]]

live ↗
InCombinatorialStat(OrderedTree⁡([[]]),DistinctSubtrees)\mathrm{CombinatorialStat}({\operatorname{OrderedTree}}(\bigl\lbrack\bigl\lbrack\bigr\rbrack\bigr\rbrack), \text{DistinctSubtrees})Out22

Known value · FindStat St000521

FindStat's value for [[[]]]

live ↗
InCombinatorialStat(OrderedTree⁡([[[]]]),DistinctSubtrees)\mathrm{CombinatorialStat}({\operatorname{OrderedTree}}(\bigl\lbrack\bigl\lbrack\bigl\lbrack\bigr\rbrack\bigr\rbrack\bigr\rbrack), \text{DistinctSubtrees})Out33

Known value · FindStat St000521

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

live ↗
InCombinatorialStat(OrderedTree⁡([[],[]]),DistinctSubtrees)\mathrm{CombinatorialStat}({\operatorname{OrderedTree}}(\bigl\lbrack\bigl\lbrack\bigr\rbrack, \bigl\lbrack\bigr\rbrack\bigr\rbrack), \text{DistinctSubtrees})Out22

Known value · FindStat St000521

About
Examples8
CrosswalkFindStat ×2