Trees - PowerPoint PPT Presentation

1 / 9
About This Presentation
Title:

Trees

Description:

Minimally connected --- T is disconnected if any edge is removed. ... descendents. There exists a unique path. from any node to any. of its descendents. ... – PowerPoint PPT presentation

Number of Views:25
Avg rating:3.0/5.0
Slides: 10
Provided by: toshi155
Category:

less

Transcript and Presenter's Notes

Title: Trees


1
Trees
A connected, acyclic, undirected graph T (V, E).

E V - 1
Minimally connected --- T is disconnected if any
edge is removed.
Maximally acyclic --- T contains a cycle if an
edge is added.
2
Rooted Tree
root, ancestor

a
internal node (not a leaf)
parent
d
b
c
node (self)
sibling
e
f
leaf(no children)
g
h
child
child
j
i
e, i, k, g, h are leaves
descendent
k
3
Subtree
root

A node and all of its descendents.
a
d
b
c
e
f
g
h
i
j
k
4
Paths in a Tree
There exists a unique path from any node to any
of its descendents.
From a parent node to its child and
other descendents.
a
d
b
c
Path 1
Path 2
f
e
h
g
i
j
Path 1 a, b, f, j Path 2 d, i
5
Depth and Height
depth 0
7
height 4
3
10
4
depth 1
node height 2
8
12
2
11
depth 2
1
depth 3
6
5
depth 4
9
6
Degree
The number of children of a node x is called
the degree of x.
degree 3
7
3
10
4
8
12
2
11
degree 1
degree 0
1
6
5
9
7
Binary Trees
Each node has at most two children.
Left child the child node on the left. Right
child the child node on the right.
A set of nodes T is a binary tree if
r
a) it is empty, or b) it consists of three
disjoint subsets 1) a root node
2) a left binary subtree 3) a
right binary subtree
a
e
b
c
f
d
right subtree
left subtree
8
Full and Complete Binary Trees
Complete binary tree
Full binary tree
Each node is either a leaf or has degree exactly
2.
All leaves have the same depth and all internal
nodes have degree 2.
9
Binary Tree Structure
a
b
c
f
e
g
Write a Comment
User Comments (0)
About PowerShow.com