Welcome to Scribd, the world's digital library. Read, publish, and share books and documents. See more
Download
Standard view
Full view
of .
Save to My Library
Look up keyword
Like this
0Activity
0 of .
Results for:
No results containing your search query
P. 1
Trees

Trees

Ratings: (0)|Views: 7 |Likes:
Published by Prateek Dhawan

More info:

Published by: Prateek Dhawan on Oct 07, 2012
Copyright:Attribution Non-commercial

Availability:

Read on Scribd mobile: iPhone, iPad and Android.
download as PDF, TXT or read online from Scribd
See more
See less

10/07/2012

pdf

text

original

 
60-254 Algorithms and Data Structures W03 Ch. 6 Trees
Scott Goodwin & Luis Rueda, 2003 1 of 104
Trees
Recursive Definition of a TreeA tree T is either empty or it consists of a root and zero ormore nonempty subtrees T
1
,T
2
,…T
each of whose roots areconnected by an edge from the root of T.
nodes, verticesarcs, edges
Root
T TT
 
60-254 Algorithms and Data Structures W03 Ch. 6 Trees
Scott Goodwin & Luis Rueda, 2003 2 of 104
The terminology of trees
A:
 Root 
of the treeB,C,D,E:
Children
of the rootB,C,D,E:
Sibblings
 E is an
ancestor 
of KK is a
descendant 
of EF,G,C,H,I,K are the
leaves
of the treeThe
depth of a node
is the
length of the path
from the root to the node
 Length of path
= # of edgesDepth of E =1
 Height of a node
= length of the longest path from that node to a leaf Height of E = 2
 Height of tree
= height of rootHeight of example tree is 3
ABHGFEDCKJI
 
60-254 Algorithms and Data Structures W03 Ch. 6 Trees
Scott Goodwin & Luis Rueda, 2003 3 of 104
Applications
Trees are a ubiquitous data structure in Computer Science.The Unix directory structure is a tree.Allows user to store files in a logical/organized fashion.Issues:
 
How to implement tree structure
 
How to insert and delete nodes in a tree structure
 
How to find nodes in a tree structure
 
How to traverse the entire tree structure
 
How to organize structure for efficiencyThese issues will be at the core of much of the discussion of trees.

You're Reading a Free Preview

Download
/*********** DO NOT ALTER ANYTHING BELOW THIS LINE ! ************/ var s_code=s.t();if(s_code)document.write(s_code)//-->