Professional Documents
Culture Documents
Trees 3
Trees 3
Distinct
Nodes
EIt.at
a
B STX
Y
H Y
est
Gx
T
3
1 76 8 118
µ
Ex 15
I BSTX
I
g 13
12
1
of
516
7
1
G 7,811118
3 11 12,3
I 76 8118
z
Distinct numbers
groot
12 9 4
ans true
0 110
Y 3
y is
6 Ig
12 9 groot
I
Y 3
I is
g
12 5 groot
ans False
0 Je
T 3
I is
s
a
int K
bool search node not
Nole
while C tmp
If Ctmp data K
Emp Emp Isbt
else if Emp data K
Emp EMP test
else
setum the
setum False
IgworstO CN
Tc Oct
Sc Oct
y
If root NULL Setum False
TC OCH
SC OCH
recursion stack
Q Given a BST Insert k in correct position
12 5 root
if fit
7
Insert K and
return
If soot data LK
f
root right Insert root right K
setum soot
TC OCH
Sc O CH
recursion stack
4
TI
ie s
dy
K
d
B g g
3 s
21 45 17 TC OCN
BST Still BST
Delete give number from
1273 6
1.5 10
181
Delete 0
2
Ceca
6
I 8510
17.5
Delete
181
12
one child
3
777.585110
4
Delete
I I
62 children 6
Ig
I 8.310
which you are trying to delete
Nolde
aia
b bz bz by
in sight
smallest child
It soot data K
soot right dude root right R
else if not data K
soot test delete not lest K
setum Noll
f
If soot test NULL
setum soot right
else
gym soot list
1
data t data
not deft date root test tmpdata
schism soot
TC O CH
Sc Oc m T recursion stack
1
balahced
Q Given a sorted array Construct a BST
I I 111213
23W
2,3
3 x 3 x
15 BBST
BBST
q
construct a B BST from an Ct 2
return soot
y int d int 2 not
Node BBST Carr CJ
t
node soot new mode arr Cmid
I
mid 5
4 5
I
Can S 47 arr 6,67
2
IN
N z
N 2 27
t
rely
holy Nf nosy 22
1 11 11 23
I
aaaaa
1 1 1 1 1 I l
I 1 1 1 11
E loan
21081 N
Q Given a Tree Find If it is BST or not
10 se
5 is
18,11
7 It sorted
1 In order
If not sorted X
TC O CN
Sc Ocn th D O CH
r tstack Icursion
incl
H
A nodes smallest in RST
largestLsts node data
BST X
5 is
Ii't
M e
soot
given
I
of
bool globalans
I o o
iii
f globalans
into ans
False
bool main C
global ans True
g BST not
i
atum ans
the
gondans kill
S
y y
is
10 a 1 BST
48.8
s
pygmy
BST NOLL
To Do of nodes
go
Q Find size
max of sobbee which is a BST
ans 3
37
mr
ingine
int mx
no of nodes
intent
bool is BST
X x x
BST t nodes
C RST
LST C not date
Search BST
Add an element BST
N 2 Wiz 2
1 My
holy f nosy 22
11 1 A 2
A 11 hahaa
t t t t
t t t t t t t t t t
Som 2 21 224 2
a 1
Sum 2kt I
d
som 22k I
D
2 I
OCN
T
I I
13
o
on 8.5 10
7S
T
I
in I
1 s io
J C 1 I 7
76
Coe a
NULL
NOU