How to define a set of trees recursively?

171 Views Asked by At

In particular, consider the set of integer-labelled binary trees (T). How could this set be defined in a recursive way from $\mathbb Z$ and T itself?

Examples:
$(-2, 1, (3, 1, 0)) \in T$
$(-1, (7, 2, 2), (3, 3, -1)) \in T$

Update: let's say that the empty tree is not considered.

1

There are 1 best solutions below

2
On BEST ANSWER

A recursive definition for binary trees already could be

  1. $() \in T$, where $()$ (the empty tuple) represents the empty tree
  2. For $k \in \mathbb{Z}$, $t_1, t_2 \in T$ we have $(k, t_1, t_2) \in T$

but it would not reproduce your intended specimens.

Those are included in this version:

  1. $() \in T$
  2. For $k \in \mathbb{Z}$ we have $k \in T$
  3. For $k \in \mathbb{Z}$, $t_1, t_2 \in T \setminus \{ () \}$ we have $(k, t_1, ()), (k, (), t_2), (k, t_1, t_2) \in T$

Update:

Without empty trees, one could only build trees where each node has either no or two sub trees:

  1. For $k \in \mathbb{Z}$ we have $k \in T$
  2. For $k \in \mathbb{Z}$, $t_1, t_2 \in T$ we have $(k, t_1, t_2) \in T$