Rooted Tree and its application
- Best prefix code
Zhaoshengnan information compute science 102 Lvna
Tree
is
one
of
the
most
important
concepts
in
Graph
Theory.
It
has
been
a
wide
range
of
applications especially in the field of computer science. What is a Tree? It is not nature of the tree,
the Tree is a finite set T which have n (n> 0) nodes, wherein: there is only a specific node, called
Rooted Tree. When n> 1, the rest of the nodes can be divided into m (m> 0) finite sets of disjoint
T1, T2 …Tm, each of
the set itself is a tree, called the Subtree of Tree.
The tree is an important
class of non-linear data structure, it is a hierarchy defined based on the branch relationship.
A
digraph
D,
if
we
omitted
the
direction
of
every
side
then
get
the
resulting
non-directed
graph become undirected tree, then D is call to the Directed-tree. In the Directed-tree rooted tree
play a very important role, and rooted tree has a wide application in the computer. Below we give
the definition of the rooted tree:
[Definition]: a non-trivial Directed-tree, if the in-degree of vertex is zero, the rest of it is one.
Then we say this is the rooted tree.
In the rooted tree, the degree of vertex 0 called the roots; the
vertices which into-degree one and out-degree zero become leaves; the vertices that into-degree
one
out
greater
than
zero
called
interior
point,
interior
point
and
the
roots
are
referred
to
as
a
branch point collectively.
According
to
the
definition
of
the
root
of
the
tree,
we
take
advantage
of
the
Huffman
algorithm to find optimal prefix encoding, Huffman algorithm:
Given real numbers
1,
2,...,
t
w
w
w
and
1
2
t
w
w
w
,
(1)
Connect two leaves which weights is
1
w
and
2
w
, to give a branch point, the weight
1
2
w
w
;
(2) Choose two minimum weights among
1
2,
3,...,
t
w
w
w
w
, connect their corresponding vertices
(not necessarily leaves), get a new branch point and weights;
(3) repeat (2), until forming t-1 branch point and t leaves.
One of the applications in communications coding to use Huffman binary tree is to construct
a
set
of
optimal
prefix
coding.
In
certain
communication
situations,
you
need
to
send
the
text
converted into a string of binary characters.
There
are
usually
two
types
of
binary-coded:
one
equal-length
encoding,
the
binary
string
length
of
such
encoding
depending
on
the
different
number
of
characters
in
the
message,
assumption only four characters in the message which needs to be transmitted, only two characters
string can be resolved, but if the message may appear in 26 different characters, such as the length
of
the
long
code
string
5.
The
other
is
unequal-length
encoding,
each
character
encoding
of
unequal length.
The benefit of unequal-length coding is the total length of the string in transmitted message
can be as shortly as possible.
There is a phenomenon the number of occurrences is not the same,
the
total
length
in
the
transmission
message
can
be
reduced
because
the
usually
individual
characters in the message.
But any one character encoding in practical unequal length coding can
not be a prefix of another character encoding, such coding is called the prefix code.
Given the definition of the prefix: