0% found this document useful (0 votes)
20 views4 pages

Tree Traversal

Tree traversal

Uploaded by

ashvanthraj26
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views4 pages

Tree Traversal

Tree traversal

Uploaded by

ashvanthraj26
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

913PVPr

(smo() 9617 wvety


ree rauesal t i on

Tavessc s a
metho tev
Tree roe exactty
all the nodle3 in Fhe
Nigtig
once

CLLe thrce Eypes


Thee Ptght
oft Root
Root
n ovdes traueisal

Ordeitaveusa RootLeft ght


Pse
Rot
PostoTdet biavcal LetRigt

B
Lorde B OoE

Post 0Tde B C A
Grl utrawsal ot Root Rtght
The inordo trauual of a
troe is
bina
Peyomed as
bo io
Traveueh the uft
Subtreetnode
Visit th 90ot
aveue tu ght 8ubtroo inovdea

Lelt

wTIte
B
(C

at(Pig) Brauy re
nordea
traveal u
A,B, e, D, EF
H,
eCurSive oubine
fos inorde traveual
Void inordes CTreo T)

iCTIE NOLL)
inorde (T- duft) ;
Printf ("zd".
TYdata);Rrint
-
inorrder CT-ght); root
Print C7- deta)
CT-7 de
Pe-ordeY travaual RODt Let Rgh
The Pro orcdey travena of a bina
Eroe iSPoutormed toloos
Visit the root
9
sbye ravee th Subtree is Preoder
Taveue tha ght Subtree is Preorder

Pe Ovde travosal of the ecbeve hgure is

Root Loft Pight

eeovder b a v s a l - FB A DCE G 1 H

RocurSIve routtne for Proorole bavensal

Voto Preordet (Tree T

f CT!=NULL)ou
Rriott C Y.d, T daba) j
Proodea CT-utt);
PrOrda (T>ight)j
Post order Traveual L Rght Poot
Peot
id Post 0rdee traveal of a
binco tre
blocuy
Pautormedby fhe fo lowing Stops
Tauy th Sabtree is Post ovder.
raveue e th at ht Subtroe is fost ovde
Visit tooot
Left RiahE Root

(D

Past ordet
haveual Ac E DBH I G

Recunsive Routi ne toPost Tden taVeual


Void postovderCTr T)
if(T! =NOLL)
Postordur (T-Ht)
Post ovcla T-ight)D
Printt (d", 7-
dala)

You might also like