0% found this document useful (1 vote)
113 views

Tree (Data Structure) : Preliminary Definition Mathematical Definition

Uploaded by

hmltdt9221
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (1 vote)
113 views

Tree (Data Structure) : Preliminary Definition Mathematical Definition

Uploaded by

hmltdt9221
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 23

Tree (data structure)

In computer science, a tree is a widely used abstract data type


(ADT) that simulates a hierarchical tree structure, with a root value
and subtrees of children with a parent node, represented as a set of
linked nodes.

A tree data structure can be defined recursively as a collection of


nodes (starting at a root node), where each node is a data structure
consisting of a value, together with a list of references to nodes (the
"children"), with the constraints that no reference is duplicated, and
none points to the root.

Alternatively, a tree can be defined abstractly as a whole (globally)


as an ordered tree, with a value assigned to each node. Both these
perspectives are useful: while a tree can be analyzed mathematically
as a whole, when actually represented as a data structure it is usually A generic, and so non-binary,
represented and worked with separately by node (rather than as a set unsorted, some labels duplicated,
of nodes and an adjacency list of edges between nodes, as one may arbitrary diagram of a tree. In this
represent a digraph, for instance). For example, looking at a tree as a diagram, the node labeled 7 has
whole, one can talk about "the parent node" of a given node, but in three children, labeled 2, 10 and 6,
general as a data structure a given node only contains the list of its and one parent, labeled 2. The root
children, but does not contain a reference to its parent (if any). node, at the top, has no parent.

Contents
Preliminary definition
Mathematical definition
Unordered tree
Sibling sets
Using set inclusion
Well-founded trees
Using recursive pairs
Using arrows
Using paths in a digraph
Using paths in a multidigraph
Using names
Pathnames
Ordered tree
Definition using horizontal order
Determinacy table
XPath Axes
Traversal maps
Generating structure
Definition using binary trees
Encoding by sequences
Per-level ordering
Terminology used in trees
Data type versus data structure
Recursive
Type theory
Mathematical
Terminology
Drawing trees
Representations
Generalizations
Digraphs
Traversal methods
Common operations
Common uses
See also
Other trees
Notes
References
Further reading
External links

Preliminary definition

Not a tree:
cycle A→A. A
is the root but it
also has a Not a tree: cycle Not a tree: Not a tree: two
parent. B→C→E→D→B. B has undirected non-connected
more than one parent cycle 1-2-4-3. 4 parts, A→B and
(inbound edge). has more than C→D→E.
one parent There is more
(inbound edge). than one root.

Each linear list is


trivially a tree

A tree is a nonlinear data structure, compared to arrays, linked lists, stacks and queues which are linear data
structures. A tree can be empty with no nodes or a tree is a structure consisting of one node called the root
and zero or one or more subtrees.
Mathematical definition

Unordered tree

Mathematically, an unordered tree[1] (or "algebraic tree"[2]) can be defined as an algebraic structure
where X is the non-empty carrier set of nodes and parent is a function on X which assigns
each node x its "parent" node, parent(x). The structure is subject to the condition that every non-empty
subalgebra must have the same fixed point. That is, there must be a unique "root" node r, such that
parent(r) = r and for every node x, some iterative application parent(parent(...parent(x)...)) equals r.
There are several equivalent definitions. As the closest alternative, one can define unordered trees as partial
algebras (X, parent) which are obtained from the total algebras described above by letting parent(r) be
undefined. That is, the root r is the only node on which the parent function is not defined and for every
node x, the root is reachable from x in the directed graph (X, parent). This definition is in fact coincident
with that of an anti-arborescence. The TAoCP book uses the term oriented tree.[3]

The box on the right contains what can be regarded as a


An unordered tree is a structure
"canonical definition" of unordered trees. It just describes the
(X, ≺) where X is a set of nodes
partial algebra (X, parent) as a relational structure (X, ≺).
and ≺ is a child-to-parent relation
Moreover, dedicated terminology can be provided for
between nodes such that:
generalizations of unordered trees that correspond to
(1) X is non-empty.
distinguished subsets of the listed conditions: (3) – directed
pseudoforest, (4) – directed acyclic graph [a], (3,4) – "unordered (2) X is weakly connected in ≺.
forest", (1,2,3) – directed pseudotree. (3) ≺ is functional.
(4) ≺ satisfies ACC: there is no
Another equivalent definition of an unordered tree is that of a infinite sequence
set-theoretic tree that is singly-rooted and whose height is at x1 ≺ x2 ≺ x3 ≺ ···.
most ω (a "finite-ish" tree[4]). That is, the algebraic structures
(X, parent) are equivalent to partial orders that have a top element r and whose every principal
upset (aka principal filter) is a finite chain. To be precise, we should speak about an inverse set-theoretic tree
since the set-theoretic definition usually employs opposite ordering. The correspondence between
(X, parent) and (X, ≤) is established via reflexive transitive closure / reduction, with the reduction
resulting in the "partial" version without the root cycle.

The definition of trees in descriptive set theory (DST) utilizes the representation of partial orders (X, ≥) as
prefix orders between finite sequences. In turns out that up to isomorphism, there is a one-to-one
correspondence between the (inverse of) DST trees and the tree structures defined so far.

We can refer to the four equivalent characterizations as to tree as an algebra, tree as a partial algebra, tree
as a partial order, and tree as a prefix order. There is also a fifth equivalent definition – that of a graph-
theoretic rooted tree which is just a connected acyclic rooted graph.

The expression of trees as (partial) algebras (X, parent) follows directly the implementation of tree
structures using parent pointers. Typically, the partial version is used in which the root node has no parent
defined. However, in some implementations or models even the parent(r) = r circularity is established.
Notable examples:

The Linux VFS where "The root dentry has a d_parent that points to itself" [5].
The concept of an instantiation tree [6] [7] [8] from object-oriented programming. In this case, the
root node is the top metaclass – the only class that is a direct instance of itself.
Note that the above definition admits infinite trees. This allows for the description of infinite structures
supported by some implementations via lazy evaluation. A notable example is the infinite regress of
eigenclasses from the Ruby object model.[9] In this model, the tree established via superclass links
between non-terminal objects is infinite and has an infinite branch (a single infinite branch of "helix" objects
– see the diagram).

Sibling sets

In every unordered tree (X, parent) there is a distinguished partition of the set X of nodes into sibling sets.
Two non-root nodes x, y belong to the same sibling set if parent(x) = parent(y). The root node r forms
the singleton sibling set {r}. [b] A tree is said to be locally finite or finitely branching if each of its sibling
sets is finite.

Each pair of distinct siblings is incomparable in ≤. This is why the word unordered is used in the definition.
Such a terminology might become misleading when all sibling sets are singletons, i.e. when the set X of all
nodes is totally ordered (and thus well-ordered) by ≤. In such a case we might speak about a singly-
branching tree instead.

Using set inclusion

As with every partially ordered set, tree structures (X, ≤) can be represented by inclusion order – by set
systems in which ≤ is coincident with ⊆, the induced inclusion order. Consider a structure (U, ℱ) such
that U is a non-empty set, and ℱ is a set of subsets of U such that the following are satisfied (by Nested
Set Collection definition):

1. ∅ ∉ ℱ. (That is, (U, ℱ) is a hypergraph.)


2. U ∈ ℱ.
3. For every X, Y from ℱ, X ∩ Y ∈ {∅, X, Y}. (That is, ℱ is a laminar family.[10])
4. For every X from ℱ, there are only finitely many Y from ℱ such that X ⊆ Y.

Then the structure (ℱ, ⊆) is an unordered tree whose root equals U. Conversely, if (U, ≤) is an unordered
tree, and ℱ is the set {↓x | x ∈ U} of all principal ideals of (U, ≤) then the set system (U, ℱ) satisfies
the above properties.

The set-system view of tree structures


provides the default semantic model – in
the majority of most popular cases, tree
data structures represent containment
hierarchy. This also offers a justification
for order direction with the root at the
top: The root node is a greater container
than any other node. Notable examples:

Directory structure of a file


system. A directory contains its
sub-directories.
DOM tree. The document parts
correspondent to DOM nodes are
in subpart relation according to
the tree order. Tree as a laminar system of sets (Copied from Nested set model)
Single inheritance in object-oriented programming. An instance of a class is also an instance of
a superclass.
Hierarchical taxonomy such as the Dewey Decimal Classification with sections of increasing
specificity.
BSP trees, quadtrees, octrees, R-trees and other tree data structures used for recursive space
partitioning.

Well-founded trees

An unordered tree (X, ≤) is well-founded if the strict partial order < is a well-founded relation. In particular,
every finite tree is well-founded. Assuming the axiom of dependent choice a tree is well-founded if and only
if it has no infinite branch.

Well-founded trees can be defined recursively – by forming trees from a disjoint union of smaller trees. For
the precise definition, suppose that X is a set of nodes. Using the reflexivity of partial orders, we can identify
any tree (Y, ≤) on a subset of X with its partial order (≤) – a subset of X × X. The set ℛ of all relations R
that form a well-founded tree (Y, R) on a subset Y of X is defined in stages ℛi, so that
ℛ = ⋃{ℛi | i is ordinal}. For each ordinal number i, let R belong to the i-th stage ℛi if and only if R
is equal to

⋃ℱ ∪ ((dom(⋃ℱ) ∪ {x}) × {x})


where ℱ is a subset of ⋃{ℛk | k < i} such that elements of ℱ are pairwise disjoint, and x is a node that
does not belong to dom(⋃ℱ). (We use dom(S) to denote the domain of a relation S.) Observe that the
lowest stage ℛ0 consists of single-node trees {(x,x)} since only empty ℱ is possible. In each stage,
(possibly) new trees R are built by taking a forest ⋃ℱ with components ℱ from lower stages and
attaching a new root x atop of ⋃ℱ.

In contrast to the tree height which is at most ω, the rank of well-founded trees is unlimited[11], see the
properties of "unfolding".

Using recursive pairs

In computing, a common way to define well-founded trees is via recursive ordered pairs (F, x): a tree is a
forest F together with a "fresh" node x.[12] A forest F in turn is a possibly empty set of trees with pairwise
disjoint sets of nodes. For the precise definition, proceed similarly as in the construction of names used in
the set-theoretic technique of forcing. Let X be a set of nodes. In the superstructure over X, define sets T,
ℱ of trees and forests, respectively, and a map nodes : T → ℘(X) assigning each tree t its underlying
set of nodes so that

(trees over X) t∈T ↔


t is a pair (F, x) from ℱ × X such that for all s ∈ F,
x ∉ nodes(s),
(forests over X) F∈ℱ ↔
F is a subset of T such that for every s,t ∈ F, s ≠ t,
nodes(s) ∩ nodes(t) = ∅ ,
(nodes of trees) y ∈ nodes(t) ↔ t = (F, x) ∈ T and
either y = x or y ∈ nodes(s) for some s ∈ F .

Circularities in the above conditions can be eliminated by stratifying each of T, ℱ and nodes into stages
like in the previous subsection. Subsequently, define a "subtree" relation ≤ on T as the reflexive transitive
closure of the "immediate subtree" relation ≺ defined between trees by
s ≺ t ↔ s ∈ π1(t)

where π1(t) is the projection of t onto the first coordinate, i.e. it is the forest F such that t = (F, x) for some
x ∈ X. It can be observed that (T, ≤) is a multitree: for every t ∈ T, the principal ideal ↓t ordered by ≤ is a
well-founded tree as a partial order. Moreover, for every tree t ∈ T, its "nodes"-order structure
(nodes(t), ≤t) is given by x ≤t y if and only if there are forests F, G ∈ ℱ such that both (F, x) and
(G, y) are subtrees of t and (F, x) ≤ (G, y).

Using arrows

Another formalization as well as generalization of unordered trees can be obtained by reifying parent-child
pairs of nodes. Each such ordered pair can be regarded as an abstract entity – an "arrow". This results in a
multidigraph (X, A, s, t) where X is the set of nodes, A is the set of arrows, and s and t are functions from
A to X assigning each arrow its source and target, respectively. The structure is subject to the following
conditions:

1) (A, s ○ t–1) is an unordered tree, as a total algebra.


2) The t map is a bijection between arrows and nodes.

In (1), the composition symbol ○ is to be interpreted left-to-right. The condition says that inverse
consecutivity of arrows[c] is a total child-to-parent map. Let this parent map between arrows be denoted p,
i.e. p = s ○ t−1. Then we also have s = p ○ t, thus a multidigraph satisfying (1,2) can also be axiomatized
as (X, A, p, t), with the parent map p instead of s as a definitory constituent. Observe that the root arrow is
necessarily a loop, i.e. its source and target coincide.

An important generalization of the above structure is


established by allowing the target map t to be many-to-one.
This means that (2) is weakened to

2') The t map is surjective – each node is the target of


some arrow.

Note that condition (1) asserts that only leaf arrows are allowed
to have the same target. That is, the restriction of t to the range
of p is still injective.

Multidigraphs satisfying (1,2') can be called "arrow trees" –


their tree characteristics is imposed on arrows rather than
nodes. These structures can be regarded as the most essential
abstraction of the Linux VFS because they reflect the hard-link
structure of filesystems. Nodes are called inodes, arrows are
dentries (or hard links). The parent and target maps p and t are
respectively represented by d_parent and d_inode fields
in the dentry data structure.[13] Each inode is assigned a fixed
file type, of which the directory type plays a special role of Arrow tree: the hard-link structure of
"designed parents": (a) only directory inodes can appear as VFS
hard-link source and (b) a directory inode cannot appear as the
target of more than one hard-link.
Using dashed style for the first half of the root loop indicates that, similarly to the parent map, there is a
partial version for the source map s in which the source of the root arrow is undefined. This variant is
employed for further generalization, see #Using paths in a multidigraph.

Using paths in a digraph

Unordered trees naturally arise by "unfolding" of accessible pointed graphs.[14] Let ℛ = (X, R, r) be a
pointed relational structure, i.e. such that X is the set of nodes, R is a relation between nodes (a subset of
X × X), and r is a distinguished "root" node. Assume further that ℛ is accessible, which means that X
equals the preimage of {r} under the reflexive transitive closure of R, and call such a structure an accessible
pointed graph or apg for short.(⁎) Then one can derive another apg ℛ' = (X', R', r') – the unfolding of
ℛ – as follows:
X' is the set of reversed paths to r, i.e. the set of non-empty finite sequences p of nodes
(elements of X) such that (a) consecutive members of p are inversely R-related, and (b) the
first member of p is the root r,
R' is a relation between paths from X' such that paths p and q are R'-related if and only if
p = q ⁎ [x] for some node x (i.e. q is a maximal proper prefix of p, the "popped" p), and
r' is the one-element sequence [r].
Apparently, the structure (X', R') is an unordered tree in the "partial-algebra" version: R' is a partial map
that relates each non-root element of X' to its parent by path popping. The root element is obviously r'.
Moreover, the following properties are satisfied:

ℛ is isomorphic to its unfolding ℛ' if and only if ℛ is a tree (⁑).


(In particular, unfolding is idempotent, up to isomorphism.)
Unfolding preserves well-foundedness: If R is well-founded then so is R'.
Unfolding preserves rank: If R is well-founded then the ranks of R and R' coincide.
Notes:

(⁎) To establish a concordancy between R and the parent map, the presented definition uses
reversed accessibility: r is reachable from any node. In the original definition by P. Aczel[14],
every node is reachable from r (thus, instead of "preimage", the word "image" applies).[d]
(⁑) We have implicitly introduced a definition of unordered trees as apgs: call an apg
ℛ = (X, R, r) a tree if the reduct (X, R) is an unordered tree as a partial algebra. This can
be translated as: Every node is accessible by exactly one path.

Using paths in a multidigraph

As shown on the example of hard-link structure of file systems, many data structures in computing allow
multiple links between nodes. Therefore, in order to properly exhibit the appearance of unordered trees
among data structures it is necessary to generalize accessible pointed graphs to multidigraph setting. To
simplify the terminology, we make use of the term quiver which is an established synonym for
"multidigraph".

Let an accessible pointed quiver or apq for short be


defined as a structure ℳ = (X, A, s, t) where X is a
set of nodes, A is a set of arrows, s is a partial
function from A to X (the source map), and t is a total
function from A to X (the target map). Thus, ℳ is a
"partial multidigraph". The structure is subject to the
following conditions:

1. There is exactly one "root" arrow, ar, whose


source s(ar) is undefined.
2. Every node x ∈ X is reachable via a finite
sequence of consecutive arrows starting with
the root arrow ar.

ℳ is said to be a tree if the target map t is a bijection


between arrows and nodes. The unfolding of ℳ is
formed by the sequences mentioned in (2) – which are
the accessibility paths (cf. Path algebra). As an apq,
the unfolding can be written as ℳ' = (X', A', s', t')
where X' is the set of accessibility paths, A' coincides
with X', s' coincides with path popping, and t' is the
identity on X'. Like with apgs, unfolding is idempotent
and always results in a tree. The underlying apg is
obtained as the structure (X, R, t(ar)) where Accessible pointed quiver (apq): generalization
of apg to multidigraphs.
R = {(t(a),s(a)) | a ∈ A \ {ar}}.

The diagram above shows an example of an apq with 1+14 arrows. In JavaScript, Python or Ruby, the
structure can be created by the following (exactly the same) code:

r = {};
r[1] = {}; r[2] = r[1]; r[3] = {}; r[4] = {};
r[1][5] = {}; r[1][14] = r[1][5];
r[3][7] = {}; r[3][8] = r[3][7]; r[3][13] = {};
r[4][9] = r[4]; r[4][10] = r[4]; r[4][11] = {};
r[3][7][6] = r[3]; r[3][7][12] = r[1][5];

Using names

Unordered trees and their generalizations form the essence of naming systems. There are two prominent
examples of naming systems: file systems and (nested) associative arrays. The multidigraph-based structures
from previous subsections provided anonymous abstractions for both cases. To obtain naming capabilities,
arrows are to be equipped with names as identifiers. A name must be locally unique – within each sibling set
of arrows[e] there can be at most one arrow labelled by a given name.

This can be formalized as a structure ℰ = (X, Σ, A, s, σ, t) where X is a set of source name target
nodes, Σ is a set of names, A is a set of arrows, s is a partial function from A to X, σ
is a partial function from A to Σ, and t is a total function from A to X. For an arrow s(a) σ(a) t(a)
a, constituents of the triple (s(a), σ(a), t(a)) are respectively a's source, name and
target. The structure is subject to the following conditions.

1. The reduct (X, A, s, t) is an accessible pointed quiver (apq) as defined previously.


2. The name function σ is undefined just for the source-less root arrow.
3. The name function σ is injective in the restriction to every sibling set of arrows, i.e. for every
non-root arrows a, b, if s(a) = s(b) and σ(a) = σ(b) then a = b.
This structure can be called a nested dictionary or named apq. In computing, such structures are ubiquitous.
The table above shows that arrows can be considered "un-reified" as the set
A' = {(s(a), σ(a), t(a)) | a ∈ A \ {ar}} of source-name-target triples. This leads to a relational structure
(X, Σ, A') which can be viewed as a relational database table. Underlines in source and name indicate
primary key. The structure can be rephrased as a deterministic labelled transition system: X is a set of
"states", Σ is a set of "labels", A' is a set of "labelled transitions". (Moreover, the root node r = t(ar) is an
"initial state", and the accessibility condition means that every state is reachable from the initial state.)

The diagram on the right shows a nested dictionary ℰ


that has the same underlying multidigraph as the
example in the previous subsection. The structure can
be created by the code below. Like before, exactly the
same code applies for JavaScript, Python and Ruby.

First, a substructure, ℰ0, is created by a single


assignment of a literal {...} to r. This structure,
depicted by full lines, is an "arrow tree" (therefore, it is
a spanning tree). The literal in turn appears to be a
JSON serialization of ℰ0.

Subsequently, the remaining arrows are created by


assignments of already existing nodes. Arrows that
cause cycles are displayed in blue.

r = {"a":{"a":5,"b":5},"c":{"a":{"w":5},"c":{}},"d":
{"w":1.3}}

r["b"] = r["a"]; r["c"]["b"] = r["c"]["a"]


r["c"]["a"]["p"] = r["c"]; r["d"]["e"] = r["d"]
["self"] = r["d"] Nested dictionary

In the Linux VFS, the name function σ is represented by the d_name field in the dentry data structure.[13]
The ℰ0 structure above demonstrates a correspondence between JSON-representable structures and hard-
link structures of file systems. In both cases, there is a fixed set of built-in types of "nodes" of which one
type is a container type, except that in JSON, there are in fact two such types – Object and Array. If the latter
one is ignored (as well as the distinction between individual primitive data types) then the provided
abstractions of file-systems and JSON data are the same – both are arrow trees equipped with naming σ and
a distinction of container nodes.

Pathnames

The naming function σ of a nested dictionary ℰ naturally extends from arrows to arrow paths. Each
sequence p = [a1, …, an] of consecutive arrows is implicitly assigned a pathname (cf. Pathname) – the
sequence σ(p) = [σ(a1), …, σ(an)] of arrow names.[f] Local uniqueness carries over to arrow paths:
different sibling paths have different pathnames. In particular, the root-originating arrow paths are in one-to-
one correspondence with their pathnames. This correspondence provides a "symbolic" representation of the
unfolding of ℰ via pathnames – the nodes in ℰ are globally identified via a tree of pathnames.

Ordered tree
The structures introduced in the previous subsection form just the core "hierarchical" part of tree data
structures that appear in computing. In most cases, there is also an additional "horizontal" ordering between
siblings. In search trees the order is commonly established by the "key" or value associated with each
sibling, but in many trees that is not the case. For example, XML documents, lists within JSON files, and
many other structures have order that does not depend on the values in the nodes, but is itself data — sorting
the paragraphs of a novel alphabetically would lose information.

The correspondent expansion of the previously described tree structures (X, ≤) can be defined by endowing
each sibling set with a linear order as follows.[16][17] An alternative definition according to Kuboyama[1] is
presented in the next subsection.

An ordered tree is a structure (X, ≤V, ≤S) where X is a non-empty set of nodes and ≤V and ≤S are relations
on X called vertical (or also hierarchical[1]) order and sibling order, respectively. The structure is subject to
the following conditions:

1. (X, ≤V) is a partial order that is an unordered tree as defined in the previous subsection.
2. (X, ≤S) is a partial order.
3. Distinct nodes are comparable in <S if and only if they are siblings:
(<S) ∪ (>S) = ((≺V) ○ (≻V)) ∖ idX.

(The following condition can be omitted in the case of finite trees.)

4. Every node has only finitely many preceding siblings, i.e. every principal ideal of (X, ≤S) is
finite.

Conditions (2) and (3) say that (X, ≤S) is a component-wise linear order, each component being a sibling
set. Condition (4) asserts that if a sibling set S is infinite then (S, ≤S) is isomorphic to (ℕ, ≤), the usual
ordering of natural numbers.

Given this, there are three (another) distinguished partial orders which are uniquely given by the following
prescriptions:

(<H) = (≤V) ○ (<S) ○ (≥V) (the horizontal order),


(<L⁻) = (>V) ∪ (<H) (the "discordant" linear order),
(<L⁺) = (<V) ∪ (<H) (the "concordant" linear order).

This amounts to a "V-S-H-L±" system of five partial orders ≤V, ≤S, ≤H, ≤L⁺, ≤L⁻ on the same set X of
nodes, in which, except for the pair { ≤S, ≤H }, any two relations uniquely determine the other three, see
the determinacy table.

Notes about notational conventions:

The relation composition symbol ○ used in this subsection is to be interpreted left-to-right (as
).
Symbols < and ≤ express the strict and non-strict versions of a partial order.
Symbols > and ≥ express the converse relations.
The ≺ symbol is used for the covering relation of ≤ which is the immediate version of a partial
order.
This yields six versions ≺, <, ≤, ≻, >, ≥ for a single partial order relation. Except for ≺ and ≻, each version
uniquely determines the others. Passing from ≺ to < requires that < be transitively reducible. This is always
satisfied for all of <V, <S and <H but might not hold for <L⁺ or <L⁻ if X is infinite.

The partial orders ≤V and ≤H are complementary: (<V) ⊎ (>V) ⊎ (<H) ⊎ (>H) = X × X ∖ idX. As a
consequence, the "concordant" linear order <L⁺ is a linear extension of <V. Similarly, <L⁻ is a linear
extension of >V.

The covering relations ≺L⁻ and ≺L⁺ correspond to pre-order traversal and post-order traversal, respectively.
If x ≺L⁻ y then, according to whether y has a previous sibling or not, the x node is either the "rightmost"
non-strict descendant of the previous sibling of y or, in the latter case, x is the first child of y. Pairs of
the latter case form the relation (≺L⁻) ∖ (<H) which is a partial map that assigns each non-leaf node its first
child node. Similarly, (≻L⁺) ∖ (>H) assigns each non-leaf node with finitely many children its last child
node.

Definition using horizontal order

The Kuboyama's definition of "rooted ordered trees"[1] makes use of the horizontal order ≤H as a definitory
relation.[g] (See also Suppes.[18]) Using the notation and terminology introduced so far, the definition can be
expressed as follows.

An ordered tree is a structure (X, ≤V, ≤H) such that conditions (1–5) are satisfied:

1. (X, ≤V) is a partial order that is an unordered tree. (The vertical order.)
2. (X, ≤H) is a partial order. (The horizontal order.)
3. The partial orders ≤V and ≤H are complementary:
(<V) ⊎ (>V) ⊎ (<H) ⊎ (>H) = X × X ∖ idX.
(That is, pairs of nodes that are incomparable in (<V) are comparable in (<H) and vice versa.)
4. The partial orders ≤V and ≤H are "consistent": (<H) = (≤V) ○ (<H) ○ (≥V).
(That is, for every nodes x, y such that x <H y, all descendants of x must precede all the
descendants of y.)

(Like before, the following condition can be omitted in the case of finite trees.)

5. Every node has only finitely many preceding siblings. (That is, for every infinite sibling set S,
(S, ≤H) has the order type of the natural numbers.)

The sibling order (≤S) is obtained by (<S) = (<H) ∩ ((≺V) ○ (≻V)), i.e. two distinct nodes are in
sibling order if and only if they are in horizontal order and are siblings.

Determinacy table

The following table shows the determinacy of the "V-S-H-L±" system. Relational expressions in the table's
body are equal to one of <V, <S, <H, <L⁻, or <L⁺ according to the column. It follows that except for the
pair { ≤S, ≤H }, an ordered tree (X, ...) is uniquely determined by any two of the five relations.
<V <S <H <L⁻ <L⁺
V,S (≤V) ○ (<S) ○ (≥V)
V,H (<H) ∩ ((≺V)○(≻V)) (>V) ∪ (<H) (<V) ∪ (<H)
V,L⁻ (<L⁻) ∩ ((≺V)○(≻V)) (<L⁻) ∖ (>V)
V,L⁺ (<L⁺) ∩ ((≺V)○(≻V)) (<L⁺) ∖ (<V)
H,L⁻ (>L⁻) ∖ (<H)
H,L⁺ (<L⁺) ∖ (<H)
L⁻,L⁺ (>L⁻) ∩ (<L⁺) (<L⁻) ∩ (<L⁺)
S,L⁻ x ≺V y ↔ y = infL⁻(Y) where Y is the image of {x} under (≥S)○(≻L⁻)
S,L⁺ x ≺V y ↔ y = supL⁺(Y) where Y is the image of {x} under (≤S)○(≺L⁺)

In the last two rows, infL⁻(Y) denotes the infimum of Y in (X, ≤L⁻), and supL⁺(Y) denotes the supremum
of Y in (X, ≤L⁺). In both rows, (≤S) resp. (≥S) can be equivalently replaced by the sibling equivalence
(≤S)○(≥S). In particular, the partition into sibling sets together with either of ≤L⁻ or ≤L⁺ is also sufficient
to determine the ordered tree. The first prescription for ≺V can be read as: the parent of a non-root node x
equals the infimum of the set of all immediate predecessors of siblings of x, where the words "infimum" and
"predecessors" are meant w.r.t. ≤L⁻. Similarly with the second prescription, just use "supremum",
"successors" and ≤L⁺.

The relations ≤S and ≤H obviously cannot form a definitory pair. For the simplest example, consider an
ordered tree with exactly two nodes – then one cannot tell which of them is the root.

XPath Axes

The table on the right shows a correspondence of introduced XPath Axis Relation
relations to XPath axes, which are used in structured document
ancestor <V
systems to access nodes that bear particular ordering relationships
to a starting "context" node. For a context node[19] x, its axis ancestor-or-self ≤V
named by the specifier in the left column is the set of nodes that
child ≻V
equals the image of {x} under the correspondent relation. As of
XPath 2.0, the nodes are "returned" in document order, which is the descendant >V
"discordant" linear order ≤L⁻. A "concordance" would be
descendant-or-self ≥V
achieved, if the vertical order ≤V was defined oppositely, with the
bottom-up direction outwards the root like in set theory in following <H
accordance to natural trees.[h]
following-sibling <S
parent ≺V
Traversal maps
preceding >H
Below is the list of partial maps that are typically used for ordered
tree traversal.[20] Each map is a distinguished functional preceding-sibling >S
subrelation of ≤L⁻ or of its opposite. self idX

≺V ... the parent-node partial map,


≻S ... the previous-sibling partial map,
≺S ... the next-sibling partial map,
(≺L⁻) ∖ (<H) ... the first-child partial map,
(≻L⁺) ∖ (>H) ... the last-child partial map,
≻L⁻ ... the previous-node partial map,
≺L⁻ ... the next-node partial map.

Generating structure

The traversal maps constitute a partial unary algebra[21] (X, parent, previousSibling, ..., nextNode)
that forms a basis for representing trees as linked data structures. At least conceptually, there are parent
links, sibling adjacency links, and first / last child links. This also applies to unordered trees in general,
which can be observed on the dentry data structure in the Linux VFS.[22]

Similarly to the "V-S-H-L±" system of partial orders, there are pairs of traversal maps that uniquely
determine the whole ordered tree structure. Naturally, one such generating structure is (X, ≺V, ≺S) which
can be transcribed as (X, parent, nextSibling) – the structure of parent and next-sibling links. Another
important generating structure is (X, firstChild, nextSibling) known as left-child right-sibling binary
tree. This partial algebra establishes a one-to-one correspondence between binary trees and ordered trees.

Definition using binary trees

The correspondence to binary trees provides a concise definition of ordered trees as partial algebras.

An ordered tree is a structure where X is a non-empty set of nodes, and lc, rs are partial maps on
X called left-child and right-sibling, respectively. The structure is subject to the following conditions:
1. The partial maps lc and rs are disjoint, i.e. (lc) ∩ (rs) = ∅ .
2. The inverse of (lc) ∪ (rs) is a partial map p such that the partial algebra (X, p) is an unordered
tree.

The partial order structure (X, ≤V, ≤S) is obtained as follows:

(≺S) = (rs),
(≻V) = (lc) ○ (≤S).

Encoding by sequences

Ordered trees can be naturally encoded by finite sequences of natural numbers.[23][i] Denote ω⁎ the set of all
finite sequences of natural numbers. Then any non-empty subset W of ω⁎ that is closed under taking
prefixes gives rise to an ordered tree: just take the prefix order for ≥V and the lexicographical order for ≤L⁻.
Conversely, for an ordered tree T = (X, ≤V, ≤L⁻) assign each node x the sequence of sibling indices,
i.e. the root is assigned the empty sequence and for every non-root node x, let w(x) = w(parent(x)) ⁎ [i]
where i is the number of preceding siblings of x and ⁎ is the concatenation operator. Put
W = {w(x) | x ∈ X}. Then W, equipped with the induced orders ≤V (the inverse of prefix order) and ≤L⁻
(the lexicographical order), is isomorphic to T.
Per-level ordering

As a possible expansion of the "V-S-H-L±" system, another


distinguished relations between nodes can be defined, based on
the tree's level structure. First, let us denote by ∼E the
equivalence relation defined by x ∼E y if and only if x and y
have the same number of ancestors. This yields a partition of the
set of nodes into levels L0, L1, ... (, Ln) – a coarsement of the
partition into sibling sets. Then define relations <E, <B⁻ and
<B⁺ by

Dashed line indicates the <B⁻ ordering


(Copied from Tree traversal)

It can be observed that <E is a strict partial order and <B⁻ and <B⁺ are strict total orders. Moreover, there is
a similarity between the "V-S-L±" and "V-E-B±" systems: <E is component-wise linear and orthogonal to
<V, <B⁻ is linear extension of <E and of >V, and <B⁺ is a linear extension of <E and of <V.

Terminology used in trees


Node
A node is a structure which may contain a value or condition, or represent a separate data structure.
Root
The top node in a tree, the prime ancestor.
Child
A node directly connected to another node when moving away from the root, an immediate
descendant.
Parent
The converse notion of a child, an immediate ancestor.
Siblings
A group of nodes with the same parent.
Neighbor
Parent or child.
Descendant
A node reachable by repeated proceeding from parent to child. Also known as subchild.
Ancestor
A node reachable by repeated proceeding from child to parent.
Leaf / External node (not common)
A node with no children.
Branch node / Internal node
A node with at least one child.
Degree
For a given node, its number of children. A leaf is necessarily degree zero. The degree of a tree is the
degree of its root.
Degree of tree
The degree of the root.
Edge
The connection between one node and another.
Path
A sequence of nodes and edges connecting a node with a descendant.
Distance
The number of edges along the shortest path between two nodes.
Depth
The distance between a node and the root.
Level
1 + the number of edges between a node and the root, i.e. (Depth + 1)
Height
The number of edges on the longest path between a node and a descendant leaf.
Width
The number of nodes in a level.
Breadth
The number of leaves.
Height of tree
The height of the root node or the maximum level of any node in the tree
Forest
A set of n ≥ 0 disjoint trees.
Sub Tree
A tree T is a tree consisting of a node in T and all of its descendants in T.
Ordered Tree
A rooted tree in which an ordering is specified for the children of each vertex.
Size of a tree
Number of nodes in the tree.

Data type versus data structure

There is a distinction between a tree as an abstract data type and as a concrete data structure, analogous to
the distinction between a list and a linked list. As a data type, a tree has a value and children, and the
children are themselves trees; the value and children of the tree are interpreted as the value of the root node
and the subtrees of the children of the root node. To allow finite trees, one must either allow the list of
children to be empty (in which case trees can be required to be non-empty, an "empty tree" instead being
represented by a forest of zero trees), or allow trees to be empty, in which case the list of children can be of
fixed size (branching factor, especially 2 or "binary"), if desired.

As a data structure, a linked tree is a group of nodes, where each node has a value and a list of references to
other nodes (its children). There is also the requirement that no two "downward" references point to the
same node. In practice, nodes in a tree commonly include other data as well, such as next/previous
references, references to their parent nodes, or nearly anything.

Due to the use of references to trees in the linked tree data structure, trees are often discussed implicitly
assuming that they are being represented by references to the root node, as this is often how they are actually
implemented. For example, rather than an empty tree, one may have a null reference: a tree is always non-
empty, but a reference to a tree may be null.

Recursive

Recursively, as a data type a tree is defined as a value (of some data type, possibly empty), together with a
list of trees (possibly an empty list), the subtrees of its children; symbolically:

t: v [t[1], ..., t[k]]

(A tree t consists of a value v and a list of other trees.)

More elegantly, via mutual recursion, of which a tree is one of the most basic examples, a tree can be
defined in terms of forest (a list of trees), where a tree consists of a value and a forest (the subtrees of its
children):

f: [t[1], ..., t[k]]


t: v f

Note that this definition is in terms of values, and is appropriate in functional languages (it assumes
referential transparency); different trees have no connections, as they are simply lists of values.

As a data structure, a tree is defined as a node (the root), which itself consists of a value (of some data type,
possibly empty), together with a list of references to other nodes (list possibly empty, references possibly
null); symbolically:

n: v [&n[1], ..., &n[k]]

(A node n consists of a value v and a list of references to other nodes.)

This data structure defines a directed graph,[j] and for it to be a tree one must add a condition on its global
structure (its topology), namely that at most one reference can point to any given node (a node has at most a
single parent), and no node in the tree point to the root. In fact, every node (other than the root) must have
exactly one parent, and the root must have no parents.

Indeed, given a list of nodes, and for each node a list of references to its children, one cannot tell if this
structure is a tree or not without analyzing its global structure and that it is in fact topologically a tree, as
defined below.

Type theory

As an ADT, the abstract tree type T with values of some type E is defined, using the abstract forest type F
(list of trees), by the functions:

value: T → E
children: T → F
nil: () → F
node: E × F → T

with the axioms:


value(node(e, f)) = e
children(node(e, f)) = f

In terms of type theory, a tree is an inductive type defined by the constructors nil (empty forest) and node
(tree with root node with given value and children).

Mathematical

Viewed as a whole, a tree data structure is an ordered tree, generally with values attached to each node.
Concretely, it is (if required to be non-empty):

A rooted tree with the "away from root" direction (a more narrow term is an "arborescence"),
meaning:
A directed graph,
whose underlying undirected graph is a tree (any two vertices are connected by exactly
one simple path),
with a distinguished root (one vertex is designated as the root),
which determines the direction on the edges (arrows point away from the root; given an
edge, the node that the edge points from is called the parent and the node that the edge
points to is called the child),

together with:

an ordering on the child nodes of a given node, and


a value (of some data type) at each node.

Often trees have a fixed (more properly, bounded) branching factor (outdegree), particularly always having
two child nodes (possibly empty, hence at most two non-empty child nodes), hence a "binary tree".

Allowing empty trees makes some definitions simpler, some more complicated: a rooted tree must be non-
empty, hence if empty trees are allowed the above definition instead becomes "an empty tree or a rooted tree
such that ...". On the other hand, empty trees simplify defining fixed branching factor: with empty trees
allowed, a binary tree is a tree such that every node has exactly two children, each of which is a tree
(possibly empty). The complete sets of operations on the tree must include fork operation.

Terminology
A node is a structure which may contain a value or condition, or represent a separate data structure (which
could be a tree of its own). Each node in a tree has zero or more child nodes, which are below it in the tree
(by convention, trees are drawn growing downwards). A node that has a child is called the child's parent
node (or ancestor node, or superior). A node has at most one parent.

An internal node (also known as an inner node, inode for short, or branch node) is any node of a tree that
has child nodes. Similarly, an external node (also known as an outer node, leaf node, or terminal node) is
any node that does not have child nodes.

The topmost node in a tree is called the root node. Depending on definition, a tree may be required to have a
root node (in which case all trees are non-empty), or may be allowed to be empty, in which case it does not
necessarily have a root node. Being the topmost node, the root node will not have a parent. It is the node at
which algorithms on the tree begin, since as a data structure, one can only pass from parents to children.
Note that some algorithms (such as post-order depth-first search) begin at the root, but first visit leaf nodes
(access the value of leaf nodes), only visit the root last (i.e., they first access the children of the root, but
only access the value of the root last). All other nodes can be reached from it by following edges or links.
(In the formal definition, each such path is also unique.) In diagrams, the root node is conventionally drawn
at the top. In some trees, such as heaps, the root node has special properties. Every node in a tree can be seen
as the root node of the subtree rooted at that node.

The height of a node is the length of the longest downward path to a leaf from that node. The height of the
root is the height of the tree. The depth of a node is the length of the path to its root (i.e., its root path). This
is commonly needed in the manipulation of the various self-balancing trees, AVL Trees in particular. The
root node has depth zero, leaf nodes have height zero, and a tree with only a single node (hence both a root
and leaf) has depth and height zero. Conventionally, an empty tree (tree with no nodes, if such are allowed)
has height −1.

A subtree of a tree T is a tree consisting of a node in T and all of its descendants in T.[k][24] Nodes thus
correspond to subtrees (each node corresponds to the subtree of itself and all its descendants) – the subtree
corresponding to the root node is the entire tree, and each node is the root node of the subtree it determines;
the subtree corresponding to any other node is called a proper subtree (by analogy to a proper subset).

Drawing trees
Trees are often drawn in the plane. Ordered trees can be represented essentially uniquely in the plane, and
are hence called plane trees, as follows: if one fixes a conventional order (say, counterclockwise), and
arranges the child nodes in that order (first incoming parent edge, then first child edge, etc.), this yields an
embedding of the tree in the plane, unique up to ambient isotopy. Conversely, such an embedding
determines an ordering of the child nodes.

If one places the root at the top (parents above children, as in a family tree) and places all nodes that are a
given distance from the root (in terms of number of edges: the "level" of a tree) on a given horizontal line,
one obtains a standard drawing of the tree. Given a binary tree, the first child is on the left (the "left node"),
and the second child is on the right (the "right node").

Representations
There are many different ways to represent trees; common representations represent the nodes as
dynamically allocated records with pointers to their children, their parents, or both, or as items in an array,
with relationships between them determined by their positions in the array (e.g., binary heap).

Indeed, a binary tree can be implemented as a list of lists (a list where the values are lists): the head of a list
(the value of the first term) is the left child (subtree), while the tail (the list of second and subsequent terms)
is the right child (subtree). This can be modified to allow values as well, as in Lisp S-expressions, where the
head (value of first term) is the value of the node, the head of the tail (value of second term) is the left child,
and the tail of the tail (list of third and subsequent terms) is the right child.

In general a node in a tree will not have pointers to its parents, but this information can be included
(expanding the data structure to also include a pointer to the parent) or stored separately. Alternatively,
upward links can be included in the child node data, as in a threaded binary tree.

Generalizations

Digraphs
If edges (to child nodes) are thought of as references, then a tree is a special case of a digraph, and the tree
data structure can be generalized to represent directed graphs by removing the constraints that a node may
have at most one parent, and that no cycles are allowed. Edges are still abstractly considered as pairs of
nodes, however, the terms parent and child are usually replaced by different terminology (for example,
source and target). Different implementation strategies exist: a digraph can be represented by the same
local data structure as a tree (node with value and list of children), assuming that "list of children" is a list of
references, or globally by such structures as adjacency lists.

In graph theory, a tree is a connected acyclic graph; unless stated otherwise, in graph theory trees and graphs
are assumed undirected. There is no one-to-one correspondence between such trees and trees as data
structure. We can take an arbitrary undirected tree, arbitrarily pick one of its vertices as the root, make all its
edges directed by making them point away from the root node – producing an arborescence – and assign an
order to all the nodes. The result corresponds to a tree data structure. Picking a different root or different
ordering produces a different one.

Given a node in a tree, its children define an ordered forest (the union of subtrees given by all the children,
or equivalently taking the subtree given by the node itself and erasing the root). Just as subtrees are natural
for recursion (as in a depth-first search), forests are natural for corecursion (as in a breadth-first search).

Via mutual recursion, a forest can be defined as a list of trees (represented by root nodes), where a node (of a
tree) consists of a value and a forest (its children):

f: [n[1], ..., n[k]]


n: v f

Traversal methods
Stepping through the items of a tree, by means of the connections between parents and children, is called
walking the tree, and the action is a 'walk' of the tree. Often, an operation might be performed when a
pointer arrives at a particular node. A walk in which each parent node is traversed before its children is
called a pre-order walk; a walk in which the children are traversed before their respective parents are
traversed is called a post-order walk; a walk in which a node's left subtree, then the node itself, and finally
its right subtree are traversed is called an in-order traversal. (This last scenario, referring to exactly two
subtrees, a left subtree and a right subtree, assumes specifically a binary tree.) A level-order walk
effectively performs a breadth-first search over the entirety of a tree; nodes are traversed level by level,
where the root node is visited first, followed by its direct child nodes and their siblings, followed by its
grandchild nodes and their siblings, etc., until all nodes in the tree have been traversed.

Common operations
Enumerating all the items
Enumerating a section of a tree
Searching for an item
Adding a new item at a certain position on the tree
Deleting an item
Pruning: Removing a whole section of a tree
Grafting: Adding a whole section to a tree
Finding the root for any node
Finding the lowest common ancestor of two nodes
Common uses
Representing hierarchical data such as syntax trees
Storing data in a way that makes it efficiently searchable (see binary search tree and tree
traversal)
Representing sorted lists of data
As a workflow for compositing digital images for visual effects
Storing Barnes-Hut trees used to simulate galaxies.

See also
Tree structure
Tree (graph theory)
Tree (set theory)
Cardinal tree and Ordinal tree
Hierarchy (mathematics)
Dialog tree
Single inheritance
Generative grammar
Hierarchical clustering
Binary space partition tree
Recursion
Fenwick tree

Other trees
Trie
Day–Stout–Warren algorithm
Enfilade
Left child-right sibling binary tree
Hierarchical temporal memory

Notes
a. Apart from the finiteness condition.
b. Alternatively, a "partial" version can be employed by excluding .
c. Arrows a and b are said to be consecutive, respectively, if t(a) = s(b).
d. However, some authors also introduce the definition with reversed reachability.[15]
e. I.e. arrows that have the same source node.
f. Here we assume that the root arrow ar is not in p.
g. Unfortunately, the author uses the term sibling order for the horizontal order relation. This is
non-standard, if not a misnomer.
h. This would also establish a concordance of the two possible directions of inequality symbols
with the categorization of XPath axes into forward axes and reverse axes.
i. In general, any alphabet equipped with ordering that is isomorphic to that of natural numbers
can be used.
j. Properly, a rooted, ordered directed graph.
k. This is different from the formal definition of subtree used in graph theory, which is a subgraph
that forms a tree – it need not include all descendants. For example, the root node by itself is a
subtree in the graph theory sense, but not in the data structure sense (unless there are no
descendants).

References
1. Tetsuji Kuboyama (2007). "Matching and learning in trees" (http://tk.cc.gakushuin.ac.jp/doc/kub
oyama2007phd.pdf#page=36) (PDF). Doctoral Thesis, University of Tokyo.
2. "The Linux VFS Model: Naming structure" (http://www.atalon.cz/vfs-m/linux-vfs-model/).
3. Donald Knuth. The Art of Computer Programming, Volume 1: Fundamental Algorithms, Third
Edition. Addison-Wesley, 1997. Section 2.3.4.2: Oriented trees (http://elganzua124.github.io/ta
ocp/OEBPS/Text/ch02b.html#page_373).
4. Unger, Spencer (2012). "Trees in Set Theory" (http://www.math.cmu.edu/~sunger/TreesTalk.pd
f#page=2) (PDF).
5. Bruce Fields. "Notes on the Linux kernel" (http://www.fieldses.org/~bfields/kernel/vfs.txt).
6. Pierre Cointe (1987). "Metaclasses are First Class: the ObjVlisp Model". Proceeding OOPSLA
'87 Conference Proceedings on Object-oriented Programming Systems, Languages and
Applications. North-Holland.
7. Wolfgang Klas, Michael Schrefl (1995). Metaclasses and Their Application: Data Model
Tailoring and Database Integration (https://archive.org/details/metaclassestheir0000klas).
Springer.
8. "What Is a Metaclass?" (http://www.atalon.cz/om/what-is-a-metaclass/).
9. "The Ruby Object Model: Data structure in detail" (http://www.atalon.cz/rb-om/ruby-object-mod
el/).
10. B. Korte, and J. Vygen (2012). Combinatorial optimization. Springer, Heidelberg.
11. Dasgupta, Abhiit (2014). Set theory: with an introduction to real point sets. New York:
Birkhäuser.
12. Makinson, David (2012). Sets, logic and maths for computing (https://books.google.com/?id=P
Pi9nvZAy8AC&pg=PA170). Springer Science & Business Media. ISBN 9781447124993.
13. Bovet, Daniel; Cesati, Marco (2005). Understanding the Linux Kernel (https://books.google.co
m/?id=h0lltXyJ8aIC&pg=PT491&dq=%22The+fields+of+the+dentry+object%22). O'Reilly.
ISBN 9780596554910.
14. Aczel, Peter (1988), Non-well-founded sets. (https://archive.org/details/nonwellfoundedse0000
acze), CSLI Lecture Notes, 14, Stanford, CA: Stanford University, Center for the Study of
Language and Information, ISBN 0-937073-22-9, MR 0940014 (https://www.ams.org/mathscin
et-getitem?mr=0940014)
15. A. S. Daghighi, M. Golshani, J. D. Hamkins, and E. Jeřábek (2014). "The foundation axiom and
elementary self-embeddings of the universe". Infinity, Computability, and Metamathematics:
Festschrift Celebrating the 60th Birthdays of Peter Koepke and Philip Welch. arXiv:1311.0814
(https://arxiv.org/abs/1311.0814). Bibcode:2013arXiv1311.0814S (https://ui.adsabs.harvard.ed
u/abs/2013arXiv1311.0814S). CiteSeerX 10.1.1.764.742 (https://citeseerx.ist.psu.edu/viewdoc/
summary?doi=10.1.1.764.742).
16. Jan Hidders; Philippe Michiels; Roel Vercammen (2005). "Optimizing sorting and duplicate
elimination in XQuery path expressions" (http://adrem.uantwerpen.be/bibrem/pubs/hidders.12.
pdf#page=5) (PDF).
17. Frithjof Dau; Mark Sifer (2007). "A formalism for navigating and editing XML document
structure" (http://dr-dau.org/Papers/sifer_dau_paper_final_version.pdf#page=10) (PDF).
International Workshop on Databases in Networked Information Systems. Springer, Berlin,
Heidelberg.
18. Suppes, Patrick (1973). "Semantics of context-free fragments of natural languages".
Approaches to Natural Language. Springer, Dordrecht: 370–394. CiteSeerX 10.1.1.398.2289
(https://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.398.2289). doi:10.1007/978-94-
010-2506-5_21 (https://doi.org/10.1007%2F978-94-010-2506-5_21). ISBN 978-90-277-0233-3.
19. "XML Path Language (XPath) 3.1" (http://www.w3.org/TR/xpath-31/). World Wide Web
Consortium. 21 March 2017.
20. "Document Object Model Traversal" (https://www.w3.org/TR/DOM-Level-2-Traversal-Range/tra
versal.html#Traversal-TreeWalker). W3C. 2000.
21. "Unary Algebras" (http://www.math.chapman.edu/~jipsen/structures/doku.php/unary_algebras).
22. J.T. Mühlberg, G. Lüttgen (2009). "Verifying compiled file system code". Formal Methods:
Foundations and Applications: 12th Brazilian Symposium on Formal Methods. Springer, Berlin,
Heidelberg. CiteSeerX 10.1.1.156.7781 (https://citeseerx.ist.psu.edu/viewdoc/summary?doi=1
0.1.1.156.7781).
23. L. Afanasiev; P. Blackburn; I. Dimitriou; B. Gaiffe; E. Goris; M. Marx; M. de Rijke (2005). "PDL
for ordered trees" (http://mashup2.science.uva.nl/marx/pub/recent/pdl-trees-final.pdf#page=3)
(PDF). Journal of Applied Non-Classical Logics. 15 (2): 115–135. doi:10.3166/jancl.15.115-135
(https://doi.org/10.3166%2Fjancl.15.115-135).
24. Weisstein, Eric W. "Subtree" (https://mathworld.wolfram.com/Subtree.html). MathWorld.

Further reading
Donald Knuth. The Art of Computer Programming: Fundamental Algorithms, Third Edition.
Addison-Wesley, 1997. ISBN 0-201-89683-4 . Section 2.3: Trees, pp. 308–423.
Thomas H. Cormen, Charles E. Leiserson, Ronald L. Rivest, and Clifford Stein. Introduction to
Algorithms, Second Edition. MIT Press and McGraw-Hill, 2001. ISBN 0-262-03293-7 . Section
10.4: Representing rooted trees, pp. 214–217. Chapters 12–14 (Binary Search Trees, Red-
Black Trees, Augmenting Data Structures), pp. 253–320.

External links
Data Trees as a Means of Presenting Complex Data Analysis (http://www.community-of-knowl
edge.de/beitrag/data-trees-as-a-means-of-presenting-complex-data-analysis/) by Sally Knipe
in August 8, 2013
Description (https://xlinux.nist.gov/dads/HTML/tree.html) from the Dictionary of Algorithms and
Data Structures
CRAN - Package data.tree (https://cran.r-project.org/web/packages/data.tree/) implementation
of a tree data structure in the R programming language
WormWeb.org: Interactive Visualization of the C. elegans Cell Tree (http://wormweb.org/celllin
eage) – Visualize the entire cell lineage tree of the nematode C. elegans (javascript)
Binary Trees by L. Allison (http://www.allisons.org/ll/AlgDS/Tree/)

Retrieved from "https://en.wikipedia.org/w/index.php?title=Tree_(data_structure)&oldid=965905744"

This page was last edited on 4 July 2020, at 03:40 (UTC).


Text is available under the Creative Commons Attribution-ShareAlike License; additional terms may apply. By using
this site, you agree to the Terms of Use and Privacy Policy. Wikipedia® is a registered trademark of the Wikimedia
Foundation, Inc., a non-profit organization.

You might also like