Professional Documents
Culture Documents
Trees 1
Trees 1
Tree
Non lina data Atratae
Nedes aranged in beachiad manr
Binay Trcs
nec he atmg tuwo children
Erer child or nghtCab
Each chid is either let
2. Ex: 0)oot
frrper
lett 8T
tree
3. Compleke BT
all the lerels ot tpee aue flled ompietey
exeept lous est rel nodes which ae filed
trom þasibe .
eX þresion
4 2
2
4
|2 13 l4
- Tnsest lDedetel
Seasch/Traverge
Tree ravercals
L. froceA o; nihing all
2.There aue nedes eh a tre’Tnea Trare
trarells
’he orde Rst order
Pre crde Jraetal ’Ih oder
L V'it the oot
2.Trarase lett sMbree io reorde
3.Travece nght ciebtreîn
prede
Prcorde I2 4 5 36 7
2
to orde TaveSal - fo pint
aerthmethe expeseion.
Exp ressiOn Tee Erdeaton
(C2x(5-1))+ (3 x2))
poctordei
* Speialiahon o Traversl
2
5
S teps
Recesive methcd etneung- the Value of c ubtree
L
inhunal hcde , combine th
2. When vsahng- an
Yolues ek srbtrees
torihm evet Expr(v
retnun y.elementl)
elce
nt eral Expr (kettl)
yé eal Expr (nghrC)
D< Opejor Rtpred at V
4
b
1
Binay seach Trce tollowing
trucluee wn the
a binaey tree data
Jt
coneins only nodes wi
tree gf anode
7 kettsus nedet kay
lessee tnan nades wit;
nade. conhains nl
kub tre ef a
2 i¡ht greate than nde's kly
eacn mtt alo be
3 att and Righ subtree
binoly scarth tree (Key)
-tnsat
iqorih m insetlx)
with root lue
In(ett 4
Inget 2
Delete
Cacel: Delete a leat node o B6t
smply remeve it .
deleke
25
4o 60
Case2 De letenede twin kingle chiad.
lopy the child to the nede to be deleta
then delee node
deleke
20
4 (bo
ase Delete node witn tuo Gidren
Fird inorde suceercor
thet ontent |.Inorder predecesco
wih tne noda to be
then de leke ncde deeted
delete
30
In orde (uc