Home Start Back Next End
  
37
Root
Depth 0
a
Node
Edge
Depth 1
b
c
Depth 2
d
e
f
g
Leaves
Height: 2
Parent-Child Relationship: a is parent of b and c
b
is child of a
b
is parent of d, e, and f
d, e, and f are children of b
c s child of a
is child of a
c s parent of g
is parent of g
g
is child of c
Figure 2.1.2.6.a. General Tree Data Structure
Similar
to
any
other
linear
data
structure, non
linear
data
structure
also
requires
a
procedure to traverse (visit) each data within
it. This
is also
true
for tree data structures.
Tree
has
its
own
unique
traversal
mechanisms
that
are
grouped
into
two
main
types,
which
are
Depth-First
Search
(DFS)
and
Breadth-First
Search
(BFS).
The
general
difference between DFS and BFS is in the use of recursion,
in which DFS towards more
on
recursive approach,
while
BFS
is
a
non-recursive approach.
A
visualization of
each
practice can be seen on figure 2.1.2.6.b
Word to PDF Converter | Word to HTML Converter