Professional Documents
Culture Documents
trees: o
a (1,6,8,2,7,16 I
=
⑧ 1
o23
-
D
4
L
S
/) -
O(N) not
good enough,find (10gN) Sol.
o
↳ Answer ->
Segmenttree.
Segment ->
Perform query age
X
(sm,
it
as prod
max,
in o(logn)
-
-
up date -
0 (logN)
ST is a
binary which
tree has interval
info & operation.
btw
Sun any
2 integer.
⑳ S 2
3456
a =
[3,8,7,6,
-
2,
-
-8,4,9] N 8 =
-
7
www -
a
0 very
27 --
-,7] -
Interval
I
0
-, o(N) to
0
24
-
[0,3I
make tree.
= >
>
[4,7]
d ↳ ↳
-
0
↓0
11
90,
R
⑲
S
8 /
-
"
nocte I
leaf
->
only
element
in
:. ST is
-
binary
Full tree. away -
it Leag
in
Nodes
suture
N
=
1:
total
modes: 2-1
(+
C
1234567
3
-
27
- e ↳ -
Se
[0,7)
- 13D 6
⑧
-
v I
.
L M13 I +
3
O3
13
t & -
6
[4,7]
S
20
I
↳
·
② ↑
t L
~Ob I
4
S
0
3
I
11
-
L -4
1
↑
-
L Mov I -
Ye
L L
V
9
⑥14 8
8
4
--
-
- -
[3] 247
[S]
[6] I
Sun btw[2,6] [2,17 (4,5)
&
=
+
(6,6) etc.
wort
was es +
-
⑪ inside-
example only
interval -
-
gerg
ex?
-
-
[4,5) -> return the value.
② Node interval is
completely outside
query
interal. (node start index) 3 Or
-
return the
defaultvalue of the
In this 0.
=
Every. age
③ erlapping: [2,6]
Ex:
I
(0,3] or
70,71
A
date
(logn) time: in a
if child
range is out, no
change
in
val, justretre
③ In the and
you will real
leag
plats by a region will
the the
up date
-
a
(3,4,,,]
=
m x 1
=
⑧
.
⑲
I
↓ W
⑲
↳