- Agraph G=(V,E)consistsofansetVofVERTICES
andasetEofedges,withE={(u,v):u,v∈V,u≠ v Atree isaconnectedgraphwithnocycles. ∃ apathbetweeneachpairofvertices.
- WhatisaTree
- Abstractmodelofa
hierarchicalstructure
- Atreeconsistsof
nodeswithaparent) childrelation
- Applications:
– Organizationcharts – Filesystems – Programming environments
- !"#
- "
#$ $ %& '# ($ )#*
- +
TreeTerminology
- Root:nodewithoutparent(A)
- (
- ,
- !
.
- Descendant ofanode:child,grandchild,grand)grandchild,etc.
- Internalnode:nodewithatleast
- nechild(A,B,C,F)
- Ancestors ofanode:parent,
grandparent,grand)grandparent,etc.
- Externalnode (a.k.a.leaf ):
nodewithoutchildren(E,I,J,K,G,H,D)
- Subtree:treeconsisting
- fanodeandits
descendants
- Depth ofanode:numberof
ancestors(=distancefromtheroot)
- Height ofatree:maximumdepthof
anynode(3)
TreeTerminology
- (
- ,
- !
.
Distancebetweentwonodes:number
- f“edges” betweenthem