Tree

Published on January 2017 | Categories: Documents | Downloads: 62 | Comments: 0 | Views: 768
of 7
Download PDF   Embed   Report

Comments

Content

Tree:
In mathematics, more specifically graph theory; a tree is an undirected graph
in which any two vertices are connected by exactly one simple path
A tree is an undirected simple graph G that satisfies any of the
following equivalent conditions:






G is connected and has no cycles.
G has no cycles, and a simple cycle is formed if any edge is added
to G.
G is connected, but is not connected if any single edge is removed
from G.
G is connected and the 3-vertex complete graph K3 is not
a minor of G.
Any two vertices in G can be connected by a unique simple path.

Any two vertices in G can be connected by a unique simple path.
An irreducible
An irreducible tree is a tree in which there is no vertex of
degree 2.
Polytree tree
A polytree or oriented tree is a directed graph with at most
one undirected path between any two vertices. In other words, a polytree is
a directed acyclic graph for which there are no undirected cycles either.
Labeled tree:
A labeled tree is a tree in which each vertex is given a unique
label. The vertices of a labeled tree on n vertices are typically given the
labels 1, 2… n.

Rooted tree
In a rooted tree, the parent of a vertex is the vertex connected
to it on the path to the root; every vertex except the root has a unique parent.
A child of a vertex v is a vertex of which v is the parent. A leaf is a vertex
without children.

In the figure, each node is labeled with an integer from {1, 2,..., 16}. Node 8
is the root of the tree. Node x is an ancestor of node y if node x is in the path
between the root and node y. For example, node 4 is an ancestor of node 16.
Node 10 is also an ancestor of node 16. As a matter of fact, nodes 8, 4, 10,
and 16 are the ancestors of node 16. Remember that a node is an ancestor of
itself. Nodes 8, 4, 6, and 7 are the ancestors of node 7. A node x is called a
common ancestor of two different nodes y and z if node x is an ancestor of
node y and an ancestor of node z. Thus, nodes 8 and 4 are the common
ancestors of nodes 16 and 7. A node x is called the nearest common ancestor
of nodes y and z if x is a common ancestor of y and z and nearest to y and z
among their common ancestors. Hence, the nearest common ancestor of
nodes 16 and 7 is node 4. Node 4 is nearer to nodes 16 and 7 than node 8 is.

Definitions for rooted trees

 A directed edge refers to the link from the parent to the child (the
arrows in the picture of the tree).
 The root node of a tree is the node with no parents. There is at most
one root node in a rooted tree.
 A leaf node has no children.
 The depth of a node n is the length of the path from the root to the
node. The set of all nodes at a given depth is sometimes called
a level of the tree. The root node is at depth zero.
 The height of a tree is the length of the path from the root to the
deepest node in the tree. A (rooted) tree with only one node (the root)
has a height of zero.
 Siblings are nodes that share the same parent node.
 A node p is an ancestor of a node q if it exists on the path from q to
the root. The node q is then termed a descendant of p.
 The size of a node is the number of descendants it has including itself.
 In-degree of a node is the number of edges arriving at that node.
 Out-degree of a node is the number of edges leaving that node.
 The root is the only node in the tree with In-degree = 0.

Ordered rooted tree:
An ordered tree or plane tree is a rooted tree for which an ordering is
specified for the children of each vertex.
Binary tree
In computer science, a binary tree is a tree data structure in which each node
has at most two child nodes, usually distinguished as "left" and "right".
Nodes with children are parent nodes, and child nodes may contain
references to their parents. Outside the tree, there is often a reference to the
"root" node (the ancestor of all nodes), if it exists. Any node in the data
structure can be reached by starting at root node and repeatedly following
references to either the left or right child.

Types of Binary tree:
Rooted binary tree
A rooted binary tree is a tree with a root node in which every node has
at most two children.
Full binary tree
A full binary tree (sometimes proper binary tree or 2-tree or strictly
binary tree) is a tree in which every node other than the leaves has two
children. Sometimes a full tree is ambiguously defined as a perfect tree.
Perfect binary tree
A perfect binary tree is a full binary tree in which all leaves are at the
same depth or same level, and in which every parent has two children.
(This is ambiguously also called a complete binary tree.)
Complete binary tree

A complete binary tree is a binary tree in which every level, except
possibly the last, is completely filled, and all nodes are as far left as
possible.
Infinite complete binary tree
An infinite complete binary tree is a tree with a count ably
infinite number of levels, in which every node has two children, so that
there are 2d nodes at level d. The set of all nodes is accountably infinite,
but the set of all infinite paths from the root is uncountable: it has
the cardinality of the continuum. These paths corresponding by an order
preserving bijection to the points of the Cantor set, or (through the
example of the Stern–Brocot tree) to the set of positive irrational
numbers.
Balanced binary tree
A balanced binary tree is commonly defined as a binary tree in which the
height of the two subtrees of every node never differ by more than
1, although in general it is a binary tree where no leaf is much farther
away from the root than any other leaf. (Different balancing schemes
allow different definitions of "much farther"). Binary trees that are
balanced according to this definition have a predictable depth (how many
nodes are traversed from the root to a leaf, root counting as node 0 and
subsequent as 1, 2... depth). This depth is equal to the integer part of log2
(n) where n is the number of nodes on the balanced tree. Example 1:
balanced tree with 1 node, log2 (1) = 0 (depth = 0). Example 2: balanced
tree with 3 nodes, log2 (3) = 1.59 (depth=1). Example 3: balanced tree
with 5 nodes, log2 (5) = 2.32 (depth of tree is 2 nodes).
Degenerate tree
A degenerate tree is a tree where for each parent node; there is only one
associated child node. This means that in a performance measurement,
the tree will behave like a linked list data structure.
Traversing binary trees:
Identify the three standard algorithms to traverse a binary tree T with root R.
Preorder:
1. Visit the root.

2. Traverse the left sub tree.
3. Traverse the right sub tree.

Inorder
1. Traverse the left sub tree.
2. Visit the root.
3. Traverse the right sub tree.

Postoreder
1. Traverse the left sub tree.
2. Traverse the right sub tree.
3. Visit the root.

Sponsor Documents

Or use your account on DocShare.tips

Hide

Forgot your password?

Or register your new account on DocShare.tips

Hide

Lost your password? Please enter your email address. You will receive a link to create a new password.

Back to log-in

Close