You are on page 1of 21

Level order traversal level by level

Lest view
Right view
vertical level order
Top view
Bottom view

3
7 Y
9 14 18

y
12 19 15 12
G

I Te
4 w i
I 14 18 NIL V2 11 2 NUT
12 19 15 12 G NI NOI NI NOI
NOLL

p
Queue inode g

9 Push Coot
C NULL
9 DOS D
sizes a
while a

Node Curr q Fonte

9 d queue c

If curs NOLL

print C Casa data

IE Ca 22 10ft IN V22

E push Car test


ummm
E Push C Carr sight
else

f
g Push null
print new line

TC O N

Sc O N
a
of Tree

1
a

ans 3,7 9 12,6

ly ans 3,719,1911817

g
T I
Ig
16
I
7
Queue inode q Node pre null

9 Push Coot
C NULL
9 DOS D
sizes a
while a

Node Curr q Fonte

9 d queue c

pre v Cu 22
If curs NOLL

IE Ca 22 10ft IN V22

E push Car test


Lacy now

E Push C Carr sight

else

f
g Push null
print new line
TC O CNS
SC O N

Paint right view


3

in of Tree

1
Iga Is ans 3 4,18 12 6

Queue inode q Node pre null

9 Push Coot
C NULL
9 DOS D
sizes a
while a

Node Curr q Fonte

9 d queue c

d
pre v Cy 22
If curs NOLL
If Ca 22.10ft IN V22

g
E push Car test

E Push Cars sight

else

q push null
a print new line
In ambiguity
O Vertical level order traversal left right

HIIIII
6 2 6 3 3 11 8 17
10,9 4

go

it

it

8
g'd tout
I
Hashmgp vertical line list hey
I
number

Hashmap int listlints hm

Monday

3
hm
y
0 9,3 1,22
a 4,11
2 12
3 917
O

É
IT

FLY y 173

h M

o 9,3
6 3 10
a a
2 1 2
27 8
3 6
3 1 17
53 si o.s5
u.T.o. hlashmaphm int lists int

int mini D
o

Queue

9 push
eine
Node

not
3
al

92 Push O
while a size o

Node Cura ql Fronte al dequeuec


int ulevel I 92 fronts 92 d queues
mini min mini ulevel
maxi max maxi ulevel

11 update bn
add cyan data in the list of veevel

anime now

91 Push Coast left


92 Push Cvlevel D

HC Curt sight I NULL


g 92 Push U level t o

force mini it maxi itt

t d b

4 d
29 8
29 11

91 92
8 G S 9,10 7 11

Top view
6 2,6 9
4,8 17
O

d
3 I
ill T
the first element of each
just print line

Bottom view
O

É I
o
Y 173

the last element of each


just print line

Types of Binary Tree

I Ipoyect Tree
All levels
Full Binary Tree Complete BT
All levels
are completely
proper BT
are completely filled
child filled except for
0 022 last level
last levels leftmost
side
All PBTU
CBT X

PD tu
Sf CBT V

PB TV
CBT V

6 f

PB TV

f 68 Btu

88686868
CB T V

63
BTV

6 68
686
O
f CB TX
6368
do 8

8 C BTV
O FT

6368
686668

FBI
CBT
PBT X
61
CBT

6666
All PBT are CBT

All CBT aren't PBT

Heist Balanced B T
For every node heightdiff of last 4
right side should not more than I

3
HBBTV

EYE

HBBTV
I É

iii
Q Find height of the Tree height Root

int height node Boot


If foot NOLL setum O

f
int e height soot left
int height root sight
seton max e p t

Q Given Tree Check If it is HBBT or not

6001 is HBBT Tae

int height node boot


If foot NOLL return O

f
int e height soot left
int height soot sight
If abscl 2 1 is HB BRI False
season maxle 2 I
Q Find diameter of the Tree

Diameter s Max btw any 2 nodes

Ia
ten path no of Nodes in path

ans Smallest 2 digit No


n
68
6 b
b b
b
6

O
I

o
fit 1 9

6 4 1 11

Ototial
off
23 1 É
94
y
ans
maxi p
int height Node Boot
If foot NOLL return O

f
int e height soot left
int o height soot sight
Maxi max 2 1 maxi
season maxle 2 I
ans S

My
No
9 Edges ans 1

X X

Level order traversal Level by levy

Rest view
Right view

vertical level order traversal


I
Top view
Bottom view

HBBT
Diameter

int height

Prints check this function call a root

g
to the's function 8D
Paint cans
now G
cart

You might also like