Professional Documents
Culture Documents
I O l l
l l O I
Multiply two
n-digit binary numbers
I O l l
#
1 0 I 1
Multiply two
n-digit binary numbers
I O l l
#
I O I L
O O O O X
Multiply two
n-digit binary numbers
I O l l
#
I O I L
O O O O X
1 0 I 1 X X
Multiply two
n-digit binary numbers
I O l l
#
I O I L
O O O O X
1 0 I 1 X X
1 0 1 1 1 1 ¥
Multiply two
n-digit binary numbers
I O l l
#
I O I L
O O O O X
1 0 I 1 X X
1011×1= 11 I
Multiply two
n-digit binary numbers
I O l l
#
I O I L
'E' O O O X
1 0 I 1 X X
1011×1= - I 1 I
Multiply two
n-digit binary numbers
I O l l
#
1 O 1 1
44
O O O O x
Cty
2 0 I 1 X X
1011×1= - 1 1 1 I
Multiply two
n-digit binary numbers
I O l l
#
1 O 1 1
44
O O O O x
Cty
I 0 1 1 X X
¢,
1011×1= - 0 1 1 1 I
Multiply two
n-digit binary numbers
I O l l
#
1 O 1 1
44
O O O O x
Cty
1 0 1 1 X X
¢,
1011×1=1000111
1
I O l l
#
1 O 1 1
44
O O O O X
Cty
1 0 1 1 X X
y,
1011×1=10001111
I O l l
#
1 O 1 1
42)
O O O O x
Cty
I 0 1 1 X X
¢,
1011×1=100 O L I I 1
X, N z RB 24
I O l l
Y, I z 43 Yg
#
1 O 1 1
44
O O O O x
Cty
I 0 1 1 X X
¢,
1011×1=100 O L I I 1
X, N z RB 14
I O l l
Y, I z 43 Yg
#
1 O 1 1
42)
O O O O x
Cty
I 0 1 1 X X
¢,
1011×1=100 O L I I 1
}
}
Multiply two
n-digit binary numbers
X, N z RB 24
I O l l
Y, I z 43 Y4
#
1 O 1 1
42)
O O O O x
Cty
I 0 1 1 X X
¢,
1 0O1 1 × 1 = 1 0
O 1 I 1 1 Anse 4
}
}
Multiply two
n-digit binary numbers
k , N z RB 14
I O l l
Y, I z 43 Yg
#
1 O 1 1
42)
O O O O x
Cty
I 0 1 1 X X
¢,
1011×1=100 O L I I 1 Anse 0
}
}
Multiply two
n-digit binary numbers
k , N z RB 14
I O l l
Y, I z 43 Yg
#
1 O 1 1
42)
O O O O x
Cty
I 0 1 1 X X
¢,
1 0 1 1 i n Ahs ← 1 0 1 1
1 0 0 O L I I 1 Anse 0
}
}
Multiply two
n-digit binary numbers
X, N z RB 24
I O l l
Y, I z 43 Yg
#
1 O 1 1
42)
O O O O x
Cty
I 0 1 1 X X
¢,
1 0 1 1 i n Ahs ← 10110
1 0 0 O L I I 2 Anse 0
}
}
Multiply two
n-digit binary numbers
k , N z RB 14
I O l l
Y, I z 43 Yg
#
1 O 1 1
44
O O O O x
Cty
I 0 1 1 X X Ans ← 100001
¢,
1 0 1 1 i n Ahs ← 10110
1 0 0 O L I I 2 Anse 0
}
}
Multiply two
n-digit binary numbers
k , N z RB 24
I O l l
Y, I z 43 Yg
#
1 O 1 1
44
O O O O x
Cty
I 0 I 1 X X Ams ← 1000010
µ,
1 0 1 1 i n Ahs ← 10110
1 0 0 O L I I 2 Anse 0
}
}
Multiply two
n-digit binary numbers
X, N z RB 24
I O l l
Y, I z 43 Yg
#
1 O 1 1
44
O O O O X Ahs← 1000010
GH
I 0 1 1 X X Ams ← 1000010
y,
1 0 1 1 i n Ahs ← 10110
1 0 0 O L I I 1 Anse 0
}
}
Multiply two
n-digit binary numbers
X, N z RB 24
I O l l
Y, I z 43 Y4
#
1 O 1 1
44
O O O O X Ahs← 10000100
GH
I 0 1 1 X X Ans ← 1000010
y,
1 0 1 1 i n Ahs ← 10110
1 0 0 O L I I 1 Anse 0
}
}
Multiply two
n-digit binary numbers
X, N z RB 24
I O l l
Y, I z 43 Yg
#
I O I 1 A n s e 1000111 I
44
O O O O X Ahs← 1 0 0 0 0 1 0 0
GH
I 0 I 1 X X Ans ← 1 0 0 0 0 1 0
y,
1 0 1 1 i n Ahs ← 10110
1 0 0 O L I I 1 Anse 0
}
}
Q: What i s the
running time of the
above code?
Multiply two
n-digit binary numbers
X, N z RB 24
I O l l
Y, I z 43 Yg
#
I O I 1 A n s e 1000111 I
44
O O O O X Ahs← 1 0 0 0 0 1 0 0
AH
I 0 I 1 X X Ans ← 1 0 0 0 0 1 0
¢,
1 0 1 1 i n Ahs ← 10110
1 0 0 O L I I 1 Anse 0
}
}
Q: What i s the
running time of the
above code?
Multiply two
n-digit binary numbers
X, N z RB 24
I O l l
Y, I z 43 Yg
#
1 0 I 1 A n s e 1000111 I
44
O O O O X Ahs← 1 0 0 0 0 1 0 0
(te)
I 0 I 1 X X Ams ← 1000010
µ,
1 0 1 1 1 1 ¥ Ahs ← 10110
1 0 0 O L I I 2 Anse 0
Q: What i s the
running time of the
above code?
A : 062)
N L K R
- a s
I O l l
l l O I
- i n
Y u T R
F F
I O I l
l l O I
i n i n
Y u T R
k i XYL R L X Y R N R X Y L RRXYR
I O I O l l l l
0 1 -
I I I
O I O l l l l
0 0 × 2 #
0 0 × -
1 0 1
I O O I O 1 0 0 I o l l
N L K R
- a s
I O l l
l l O I
i n i n
Y u T R
k i XYL R L X Y R N R X Y L RRXYR
I O I O l l l l
0 1 -
I I I
O I O l l l l
0 0 × 2 #
0 0 × -
1 0 1
I O O I O 1 0 0 I o l l
l l O I
i n i n
Y u T R
k i XYL R L X Y R N R X Y L RRXYR
I O I O l l l l
0 1 -
I I I
O I O l l l l
0 0 × 2 #
0 0 × -
1 0 1
I O O I O 1 0 0 I o l l
1 ¥
F F
I O I l
l l O I
i n i n
Y u T R
k i XYL R L X Y R N R X Y L RRXYR
I O I O l l l l
0 1 -
I I I
O I O l l l l
0 0 × 2 #
0 0 × -
1 0 1
I O O I O 1 0 0 I o l l
11011 O l l
N L K R
- a s
I O l l
l l O I
i n i n
Y u T R
k i XYL R L X Y R N R X Y L RRXYR
I O I O l l l l
0 1 -
I I I
O I O l l l l
0 0 × 2 #
0 0 × -
1 0 1
I O O I O 1 0 0 I o l l
11011 O l l TR-a
N L K R
- a s
I O l l
l l O I
i n i n
Y u T R
k i XYL R L X Y R N R X Y L RRXYR
I O I O l l l l
0 1 -
I I I
O I O l l l l
0 0 × 2 #
0 0 × -
1 0 1
I O O I O 1 0 0 I o l l
1 ¥
I O l l TR. N
x x
F F
I O I l
l l O I
i n i n
Y u T R
k i XYL R L X Y R N R X Y L RRXYR
I O I O l l l l
0 1 -
I 0 1 I
O I O l l l l
0 0 × 2 #
0 0 × -
1 0 1
I O O I O 1 0 0 I o l l
1 ¥
I O l l TR-a
1 0 0 0 0 1 ¥ Y u - K
I O O O l l l l
N L K R
- a s
I O l l
l l O I
i n i n
Y u T R
k i XYL R L X Y R N R X Y L RRXYR
I O I O l l l l
0 1 -
I I I
O I O l l l l
0 0 × 2 #
0 0 × -
1 0 1
I O O I O 1 0 0 I o l l
1 1 0 1 1- I RR × Y R
N L K R
- a s
I O l l
l l O I
i n i n
Y u T R
k i XYL R L X Y R N R X Y L RRXYR
I O I O l l l l
0 1 -
I 0 1 I
O I O l l l l
0 0 × 2 #
0 0 × -
1 0 1
I O O I O 1 0 0 I o l l
1 1 0 1 1- I RR × Y R
0 I 0 X X R L × Y R
N L K R
- a s
I O l l
l l O I
i n i n
Y u T R
k i XYL R L X Y R N R X Y L RRXYR
I O I O l l l l
0 1 -
I I I
O I O l l l l
0 0 × 2 #
0 0 × -
1 0 1
I O O I O 1 0 0 I o l l
1 1 0 1 1- I RR × Y R
0 I 0 X X R L × Y R
I O O 1 X X K R X Y u
N L K R
- a s
I O l l
l l O I
i n i n
Y u T R
k i XYL R L X Y R N R X Y L RRXYR
I O I O l l l l
0 1 -
I I I
O I O l l l l
0 0 × 2 #
0 0 × -
1 0 1
l O O I 0 1 0 0 I o l l
1 1 0 1 1- I RR × Y R
0 I 0 X X R L × Y R
I O O 1 X X K R X Y u
l # X X X K L X T L
N L K R
- a s
I O l l
l l O I
i n i n
Y u T R
k i XYL R L X Y R N R X Y L RRXYR
I O I O l l l l
0 1 -
I I I
O I O l l l l
0 0 × - 1 1 × 2
0 0 × -
1 0 1
I O O I O 1 0 0 I o l l
1 1 0 1 1- I RR × Y R
0 I 0 X X R L × Y R
I O O 1 X X K R X Y u
l # X X X K L X Y L
I O O O l l l l
MULTIPLY (x,y)
{ n e se,... serzl
R R ←
K¥+1... U n
Yu ← y,....
Yn z
YR ←
YEH... I n
MULTIPLY (se,y)
{ x < ← se,... serzl
R R U n
←
k¥+1...
Y , ← y,....
Yn z
YR ←
YEH... I n
A, ← M U LT I P LY (dude)
Az ← MULTIPLY (Nc,YR)
Az ← MULTIPLY (Uk,Y2)
A-4 ←
MULTIPLY (dr.IR)
MULTIPLY (se,y)
{ x , ← se,... senz'
R R ←
K¥+1... U n
Y L ← y,....
Yn z
YR ←
YEH... I n
A, ← M U LT I P LY (kudu)
Az ← MULTIPLY ( N c ,Ye )
Az ← MULTIPLY (Uk,Y2)
A-4 ←
MULTIPLY (HR,YR)
Append A, by n z e r o e s
Append Az of A z by N z zeroes
x , ← se,...
renz
R R U n
←
k¥+1...
Y , ← y,....
Yn z
YR ←
YEH... I n
A, ← M U LT I P LY (kudu)
Az ← MULTIPLY ( N c ,Ye )
Az ← MULTIPLY (UR,Y2)
A-4 ←
MULTIPLY (HR,YR)
Append A, by n z e r o e s
Append Az of A z by 4 2 zeroes
}
{ x , ← se,... senz'
R R ←
k¥+1... U n 06)
" L ← y,....
gz
YR ←
YEH... I n
:::'t:i::::::::}:*:
A, ← M U LT I P LY (nudie) T (nk)
A-4 ←
MULTIPLY (dr.TK) T
(%)
Append
Append
A,
Az
by
of A z
n z e r o e s
by 4 2 zeroes
} Oh)
}
{ x , ← se,... senz'
R R ←
k¥+1... U n 06)
" L ← y,....
gz
YR ←
YEH... I n
:÷÷÷:":*.'':*:}:*:
A, ← M U LT I P LY (nudie) T (nk)
A-4 ←
MULTIPLY (hr.TK) T
(%)
Append
Append
A,
Az
by n
of A z by N z
z e r o e s
zeroes
} Oln)
Tln) = 4 T
(2) t C n
Tln)
MULTIPLY (se,y)
}
{ x , ← se,... senz'
R R ←
k¥+1... U n 06)
" L ← y,....
gz
YR ←
YEH... I n
:::'t:÷:*:c:*:}:*:
A, M U LT I P LY (kudu) T(n/z)
←
A-4 ←
MULTIPLY (hr.TK) T
(%)
Append
Append
A,
Az
by n z e r o e s
of A z by n / z z e r o e s
} Oln)
Tln) = 4 T
(2) t C n
= ON
CARL FREDRICK GAUSS ONCE N OT I C E D.
Q: CAN T H I S BE CALCULATED IN 3
MULTIPLICATION?
CARL FREDRICK GAUSS ONCE N OT I C E D.
Q: CAN T H I S BE CALCULATED IN 3
MULTIPLICATION?
bet a d =
@+b) (Cta) - a c - b d
i n i n
-
REQUIRED.
CARL FREDRICK GAUSS ONCE N OT I C E D.
Q: CAN T H I S BE CALCULATED IN 3
MULTIPLICATION?
bet a d =
@+b) (Cta) - a c - b d
i n i n
-
REQUIRED.
1 1 0 1 l- I R R X T R
O I O X X R L × Y R
I O O 1 X X K R X Y u
l # X X X K L X Y L
I O O O l l I I
I O l l
1 1 0 1 1- I RR × Y R
0 I 0 X X R L × Y R
I 0 O l X × U R X Y u
l # X X X K L X YL
I O O O l l l l
1 1 0 1 1- I RR × T R
I O I 1 X X R L × Y R t ARXYL
l # X X X K L X Y L
I O O O l l l l
N LYR t KRYL =
Clutter) (1+912) a R LY L- K R Y R
I O l l
1 1 0 1 1- I RR × T R
I O I l X X l e c t o r ) ( Ye r ) -NTL-ARTE
l # X X X - L X Y L
I O O O l l l l
N LYR t KRYL =
flutter)(YLtYR) - R h y l - K R Y R
MULTIPLY (se,y)
{ x , ← se,... senz'
R R ←
K¥+1... U n
Y L ← y,....
Yn z
YR ←
YEH... I n
A, ← M U LT I P LY (kudu)
Az ← MULTIPLY ( N c ,Ye )
Az ← MULTIPLY (UR,Y2)
A-4 ←
MULTIPLY (HR,YR)
Append A, my
by 2
z e r o e s
Append Az of A z by n zeroes
x , ← se,... senz
R R U n
←
k¥+1...
Y , ← y,....
Yn z
YR ←
YEH... I n
A, ← M U LT I P LY (kudu)
Az ← MULTIPLY (dr.TK)
A g ← SUBTRACT (Az, A i , A z )
Append A , n
byz e r o e s
Append Az by z e r o e s
nz
return ADDC A i , Az,Aa)
}
MULTIPLY (x,y)
}
{ x , ← se,... senz'
R R ←
k¥+1... U n 047
" L ← y,....
gz
y r ←
YEH... I n
O(n)
A, ← M U LT I P LY (nudie) ) ADDLYL.
)
(ADDCRL.dk),
br))}¥¥¥
Az ← MULTIPLY
Arg ←
MULTIPLY ftp.YRD TIE)
A4 ← SUBTRACT (Az, A i , -As) } 0 (n)
Append A i
Append
n
by
z e r o e s
Az by z e r o e s
} Oh)
nz
return ADDC A i , Az,Aa) }0ln)
}
Th) 3 T
(2) t
=
e n
.
MULTIPLY (se,y)
}
{ x , ← se,... senz'
R R ←
k¥+1... U n Old
" L ← y,....
gz
y r ←
YEH... I n
O(n)
A, ← M U LT I P LY (dude) ) ADDLYL.
)
(ADDCRL.dk),
br))}¥¥¥
Az ← MULTIPLY
Ago ←
MULTIPLY ftp.YRD TIE)
A4 ← SUBTRACT (Az, A i , -As) } 0 (n)
Append A i
Append
n z e r o e s
by
Az by z e r o e s
}o h )
nz
foln)
return ADDC A i , Az,Aa)
g
Tln) 3 T
(2) t
=
e n
= 31691
10923
=
n
= n l .5 9
Xnxn Ynxn
Z nx n =
Xuan Y u n
i. ii. It.. I
Xnxn Ynxn
Znxn =
Xuan Y u n
j
III. 111ft
n
Zig'
Zij
=
E Xia-Yaj
12=1
Znxn =
Xuan Y u n
j
t.tl#.A..i n
Zig'
=
E Xia-Yaj
12=1
TIME TO F I N D 2 = Off).
.
I
O
1
l
[ O O
l l
O
l
O
O
O O
O I
1
2
2
1
0
0
1
2
X T Z
.
÷:*. #÷:*:
÷::.it:
i
. 2 I 0 2
A-fo;] Bite
it off it. '19,1'
÷÷÷¥t÷÷÷t÷
i
.÷÷
⇐
to;] ' I i it 4¥
it. I
'Io,
'
⇐
I : :I I::'t
⇐
91%1 "I:{I
÷::t÷i÷÷÷i÷÷
i
.÷
⇐
to;] ' I i it 4¥
it. I
'Io,
'
to. 1. 91%1
⇐
"t::'t "I:#
*
I:# 'IE, it
i÷÷÷i÷÷÷i÷÷:
*:
A-fo;] ' I i it 4¥
it. I
'Io,
'
-fo. It
e - ⇐
too:I 91%1 "I:#
E-f: I] F -
for]
0 I
Gtfo of
1 O
Hel
o O
of
1
I:#x Ea.it#::.:.a::::it
I
8 of
multiplication matrices of s i z e s
EX ¥
& 4 ADDITIONS.
MATRIX-MULL X , y )
{ some base condition
Using x → construct A . B .G D
.
MATRIX-MULL X . y )
{ some base condition
Using x → construct A . B .G D
AE=
MATRIX-MULLAIE)
BG= M AT R I X- M U L (B.G )
AF= MATRIX-MUL (A,F)
BH= M AT R I X- M i l l (B,H)
C E - M AT R I X- M i l l (GE)
DG= MATRIX-MUL(D,G)
(F- MATRIX-MULIC, F )
D H= MATRIX-MULL D,H)
MATRIX-MULL X , y )
{ some base condition
Using x → construct A . B .G D
A E=
MATRIX-MULLAIE)
BG= M AT R I X- M U L (B.G )
AF= MATRIX-MUL (A,F)
BH= M AT R I X- M i l l (B,H)
CE= M AT R I X- M i l l (GE)
DG= MATRIX-MUL(D,G)
(F- MATRIX-MULIC, F )
D H= MATRIX-MULL D,H)
P ← ADDCAE.BG)
& ←
ADD (AF, BH)
R ←
A D D(CE,DG)
5 ← A D D (CF, DH)
MATRIX-MULL X , y )
{ some base condition
Using x → construct A . B .G D
A E=
MATRIX-MULLAIE)
BG= M AT R I X- M U L (B.G )
AF= MATRIX-Mill (A,F)
BH= M AT R I X- M i l l (B,H)
CE= M AT R I X- M i l l (GE)
DG= MATRIX-MUL(D,G)
(F- MATRIX-MULIC, F )
D H= MATRIX-MULL D,H)
P ← ADDCAE.BG)
& ←
ADD (AF, BH)
R ←
A D D(CE.BG)
s ← A D D (CF, DH)
}
2=1:$
MATRIX-MULL X , y )
{ some base condition } 014
A E= MATRIX-MULLA,E)
BG= M AT R I X- M U L (B.G )
AF= MATRIX-Mill (A,F)
BH= M AT R I X- M i l l (B,H)
CE= M AT R I X- M i l l (GE)
DG= MATRIX-MUL(D,G)
(F- MATRIX-MULIC, F )
D H= MATRIX-MULL D,H)
P ← ADDCAE.BG)
& ←
ADD (AF, BH)
R ←
A D D(CE.BG)
s ← A D D (CF, DH)
}
2=1:$
Ten)
MATRIX-MULL X , y )
{ some base condition } 014
{8
A E= MATRIX-MULLA,E)
BG= M AT R I X- M U L (B.G )
AF= MATRIX-MUL (A,F)
iii. 'III:#'I::i:# TH
' '
DG= MATRIX-MUL(D,G)
(F- MATRIX-MULIC, F )
D H= MATRIX-MULL D ,H)
P ← ADDCAE.BG)
& ←
ADD (AF. -BH)
R ←
A D D(CE,DG)
5 ← A D D (CF, DH)
}
2=1:$
TG )
MATRIX-MULL X , y )
{ some base condition } 014
µ'
A E= MATRIX-MULLA,E)
BG= M AT R I X- M U L (B.G )
AF= MATRIX-MUL (A,F)
iii. 'III:#'iii.i:#
' '
D G= MATRIX-MUL(D,G)
(F- MATRIX-MULIC, F )
D H= MATRIX-MULL D ,H)
(
P ← ADDCAE.BG)
Olof)
Q ←
ADP (AFI-
R ←
A D DBH)
( L E DG)
5 ← A D D (CF, DH)
}
2=1:$
TG )
MATRIX-MULL X , y )
{ some base condition } 014
Using Y → construct E . F , G ,H
§'
A E= MATRIX-MULLA,E)
BG= M AT R I X- M U L (B.G )
AF= MATRIX-MUL (A,F)
iii. 'III:#'iii.i:#
' '
D G= MATRIX-MUL(D,G)
(F- MATRIX-MULIC, F )
D H= MATRIX-MULL D ,H)
}
P ← ADDCAE.BG)
Q (AF, BH) Olof)
←
ADD
R ←
A D D(CE.BG)
s ← A D D (CF. DH)
⇐ (ppg) 3044
}
Tbh) cri
(z)
=
8 T t
Tbh) cri
(z)
=
8 T t
= 0 ( n3)
FOR A LO N G LONG TIME EVERYONE BELENED
Pz =
(AtB) H
p, = CADE
Pg = DIG-E)
Ps =
(AtD) (Eth)
Po = (B-D)(Gitt)
B- = CA-c) ( E f f )
I N 1961, V O L K E R STRASSEN CAME UP WITH T H I S
Pz =
(AtB) H
p, = CADE xY= [Aft B G DH
AftBH
Pg = DIG-E) C E t CF+]
DG
B- =
(AtD) (Eth)
Po = (B-D)(GTA)
B- = CA-c) ( E f f )
Ps tPa - Pa t B =
(AtD)(ETH) t D(G-E) (AtB )H
-
(B-D)(GH)
I N 1961, V O L K E R STRASSEN CAME UP WITH T H I S
Pz =
(AtB) H
p, = CADE XY= [AE t B G DH
AftBH
Pg = DIG-E) C E t CF+]
DG
B- =
(AtD) (Eth)
Po = (B-D)(Gitt)
B- = CA-c) ( E f f )
Ps tPa - Pa t B =
(AtD)(ETH) t D(G-E) (AtB )H -
(B-D)(GH)
=
A E+ AH + E D T DH + DG-DE
-
AH-BH + 1 3 G t B H - D G - D H
I N 1961, V O L K E R STRASSEN CAME UP WITH T H I S
Pz =
(AtB) H
p, = CADE xY= [Aft B G DH
AftBH
D (G-E)
Pg CF+]
=
⇐ t DG
Psi (AtD) (Eth)
Po = (B-D)(GTA)
B- = CA-c) ( E f f )
Ps tPa - Pa t B =
(AtD)(ETH) t D(G-E) (AtB )H t
-
(B-D)(GH)
= AEtAH/tE/DtD/HtD/G-DA
- Aft-1/34 + BG-11/34-DIG-DX
I N 1961,, V O L K E R STRASSEN CAME UP WITH T H I S
Pz =
(AtB) H
p, = CADE xY= [Aft B G DH
AftBH
D (G-E)
Pg CF+]
=
⇐ t DG
Psi (AtD) (Eth)
Po = (B-D)(GTA)
B- = CA-c) ( E f f )
Ps tPa - Pa t B =
(AtD)(ETH) t D(G-E) (AtB )H t
-
(B-D)(GH)
= AEtAH/tE/DtD/HtD/G-DA
- Aft-1/34 + BG-11/34-DIG-DX
= AETBG.
I N 1961, V O L K E R STRASSEN CAME UP WITH T H I S
Pz =
(AtB) H
p, = CADE xY= [Aft B G DH
AftBH
Pg = DIG-E) ⇐ t CF+]
DG
B- =
(AtD) (Eth)
Po = (B-D)(GTA)
B- = CA-c) ( E f f )
Ps tPa - Pa t B =
(AtD)(ETH) t D(G-E) (AtB )H t-
(B-D)(GH)
= AEtAH/tE/DtD/HtD/G-DA
- Aft-1/34 + BG-11/34-DIG-DX
= AETBG.
XY = (Ps-1194- P s t Ps-Pstp]
PL
PztP6
BtP4 Pst
I N 1961, V O L K E R STRASSEN CAME UP WITH T H I S
Pz =
(AtB) H
p, = CADE xY= [Aft B G CFtD
AftBH
Pg = DIG-E) CET H]
DG
B- =
(AtD) (Eth)
Po = (B-D)(GTA)
B- = CA-c) ( E f f )
Ps tPa - Pa t B =
(AtD)(ETH) t D(G-E) (AtB )H t -
(B-D)(GH)
= AEtAH/tE/DtD/HtD/G-DA
- Aft-1/34 + BG-11/34-PIG-DA
= AETBG.
XY = (Ps-1194- P s t Ps-
PL
PztP6
BtP4 P s t Ps-1Pa]
MAIN-OBSERIATION: 7 MULTIPLICATIONS
Pz =
(AtB) H
p, = CADE xY= [Aft B G CFtD
AftBH
Pg = DIG-E) CET H]
DG
B- =
(AtD) (Eth)
Po = (B-D)(GTA)
B- = CA-c) ( E f f )
Ps tPa - Pa t B =
(AtD)(ETH) t D(G-E) (AtB )H t -
(B-D)(GH)
= AEtAH/tE/DtD/HtD/G-DA
- Aft-1/34 + BG-11/34-PIG-DA
= AETBG.
XY = (Ps-1194- P s t Ps-
PL
PztP6
BtP4 P s t Ps-1Pa]
MAIN-OBSERIATION: 7 MULTIPLICATIONS
1- (n) =
7MHz) + c . n'
Tln) = O@1084 = 01,281).
Tln) = 041084 = 01,281).
01ns-373)
C u r re n t best algo :
PROBLEM: GIVEN n POINTS P= {Pi,Pz,....,Pn}
ON A EUCLIDEAN PLANE ( d(pi,pj) =
FIND A PA I R O F POINTS P i . Pj T H AT
MINIMIZES d(peipj)
PROBLEM: GIVEN i n POINTS {Pi,Pz,....,Pn]
P=
FIND A PA I R O F POINTS P i . Pj T H AT
MINIMIZES d(peipj)
• •
•
-Pj
pie
.
• a a o
• o o
PROBLEM: GIVEN n {Pi,Pz,....,Pn] POINTS P=
FIND A PA I R O F POINTS P i . Pj T H AT
MINIMIZES d(peipj)
• •
•
-Pj
pie
.
• a a .
• o •
LINE ?
• @ o • • , a n
FIND A PA I R O F POINTS P i . Pj T H AT
MINIMIZES d(peipj)
• •
•
-Pj
pie
.
• a a o
• o •
LINE ?
• @ o • • , a ,
FIND A PA I R O F POINTS P i . Pj T H AT
MINIMIZES d(peipj)
• •
•
-Pj
pi)
.
• a o .
• o •
LINE ?
• @ o • • , a ,
• •
• • a
• a • a o
• o •
• •
• • a
• a • a o
• a •
Pu ←
Points SORTED USING R - C O O R D I N AT E
Py ←
points SORTED Using
g-
co-ORDINATE
TA K E S Olnlogn) TIME
R
G
o
i
•
f
I
'
• a a
• a • a o
.
. .
LINE L .
R
B
\ °
Foy .
. TRY
"
• • a
• " " °
I
• a •
On
→ → Ra
LINE l .
R
B
§ °
To y .
. TRY
"
• • a
• • " °
/
• o o
b e
→ → Ra
LINE L .
TAKES 0 ( ) TIME
R
B
| a
4.O y .
. TRY
"
• • a
• " " °
Y
• o o
b e
→ → Ra
LINE L .
TAKES 0 ( n ) TIME
R
B
§ a
To y .
. DRY
"
• • a
.
"£ "
£"
/
• o o
b e
→ → Ra
LINE L .
TAKES 0 ( n ) TIME
R
B
§ a
toy .
. try
"
• o
g a
.
"£ "
£"
/
• o o
One
→ → Ra
LINE L .
TAKES 0 ( n ) TIME
d(90,9.) = s e dlro.sn)
R
B
| a
To y .
. TRY
"
• o
g a
.
"£ "
£"
/
• o o
One
→ → Ra
LINE L .
TAKES 0 ( n ) TIME
d(90,9.) = s e dlro.sn)
I s 8 THE ANSWER?
R
|
G
i
To y .
TRY
q§
i
• o
g o
•
90¥, of"
.
g
• o o
One
→ → Ra
LINE L .
TAKES 0 ( n ) TIME
d(go,%) = s e dlro.sn)
I s 8 THE ANSWER?
N O , THERE M AY BE Tw o POINTS
q E @ f r E R s . t d(girl e s .
R
|
G
i
4.O y .
TRY
q§ o f "
i
• o
g o
•
90¥,
.
L a n -
g
dl9.lt/8d%eas
• o o
d a
→ → Roe
LINE l .
TAKES 0 ( n ) TIME
d(go,%) = s e dlro.sn)
I s 8 THE ANSWER?
N O , THERE M AY BE Tw o POINTS
q E @ f r E R s . t dlgirl < 8.
R
G
o
i
F¥Y¥s"
- o
4.O y .
HERE f ← rap an
HERE
PontstRy
gif
.
900 8 .
•
al: £"
.
L a n -
#: I
• o •
dig, d l r,e k 8
One
→ → Ra
LINE L .
TAKES 0 ( n ) TIME
d(go,%) = s e dlro.sn)
I s 8 THE ANSWER?
N O , THERE M AY BE Tw o POINTS
← s → ← 8 →
/
;
i ,
i i
i ,
i ,
i :
i i
t
/
t
\
/
/ i
, i
i
,
/ I
: i
s
/
i
l
l
,
t. .
. .
FIND ALL POINTS AT A D I S TA N C E £ 8
FROM LINE l .
← s → ← 8 →
: / :
;
i ,
i i
i i
i i
l
,
l
,
/
, i
, i
i
,
/ I
: i
c
/
i
l
l
,
t. .
. .
← s → ← 8 →
/
;
1 i i
• i l
i l
2 i i
! i;
•
oil
p
i .
I
I ,
'
'
5 q
:/
| I
• , i
I
l g
I l
•
i !
I
|
i g I
o
i
l
F l
i
,
• . .
Py =
7 9 6 8 5 4 3 11 2 I
FIND ALL POINTS AT A D I S TA N C E £ 8
FROM LINE l .
← s → ← 8 →
/
;
1 i i
•
: i
2 i i
! i;
•
oil
p
i .
I
I ,
'
'
5 q
:/
| I
• , i
I
l g
I l
•
i !
I
|
i g I
o
i
l
F l
• : :
Py =
7 9 6 8 5 4 3 11 2 I
Sg =
Set OF ALL POINTS AT A DISTANCE
E 8 FROM LINE 1 .
FIND ALL POINTS AT A D I S TA N C E 1 8
FROM LINE l .
← s → ← 8 →
/
;
1 i i
•
: i
2 i i
! i;
•
oil
p
i .
I
I ,
'
'
5 q
:/
| I
• , i
I
l g
I l
•
i !
I
|
i g I
o
i
l
F l
i
,
• . .
Py =
7 9 6,85 4 3 11 2 I
Sy
=
9 6 8 4 3
FIND ALL POINTS AT A D I S TA N C E £ 8
FROM LINE l .
← s → ← 8 →
/
;
1 i i
•
: i
2 i i
! i;
•
oil
p
i .
I
I ,
'
'
5 q
:/
| I
• , i
I
l g
I l
•
i !
I
|
i g I
o
i
l
F l
• : :
Py =
7 9 6 8 5 4 3 11 2 I
Sy
=
9 6 8 4 3
← s → ← 8 →
/
;
1 i i
•
: i
2 i i
! i;
•
oil
p
i .
I
I ,
'
'
5 q
:/
| I
• , i
I
l g
I l
•
i !
I
|
i g I
o
i
l
F l
• : :
Py =
7 9 6 8 5 4 3 11 2 I
Sy
=
9 6 8 4 3
← s → ← 8 →
/
;
1 i i
•
: i
2 i i
! i;
•
o "
p
i .
I
I ,
'
'
5 q
:/
| I
• , i
I
l g
I l
•
i !
I
|
i g I
o
i
l
F l
• : :
Py =
7 9 6 8 5 4 3 11 2 I
Sy
=
9 6 8 4 3
TAKES 044
COMPARE EACH PAIR IN Sg-1 TIME
THER.CM#BEzYz
BUT POINTS I N Sy
FIND ALL POINTS AT A D I S TA N C E £ 8
FROM LINE l .
← s → ← 8 →
/
;
1 i i
•
: i
2 i i
! i;
•
oil
p
i .
I
I ,
'
'
5 q
:/
| I
• , i
I
l g
I l
•
i !
I
|
i g I
o
i
l
F l
• : :
Py =
7 9 6 8 5 4 3 11 2 I
Sy
=
9 6 8 4 3
← s → ← 8 →
/
;
1 i i
•
: i
2 i i
! i;
•
oil
p
i .
I
I ,
'
'
5 q
if:
| I
• , i
' 8 'T
'
o
'
8/2
i:
i g
I
I
i o
l
8/2
7 i
• : i t
←
%→←sb→←s1z→←sb→
Py =
7 9 6 8 5 4 3 11 2 I
Sy
=
9 6 8 4 3
← 8. → ← 8 →
-
;
'
1 '
,
'
I
,
• i .- - - - - - i - - - - - - - - - - - - -
' --------l.
' '
' '
' ' l
2 , ,
l
'i....? - ÷ . . . f.....-÷-....:
• I , i
' '
I l
o "
i c
i
l
l ! o i ,
'
'
5 '
4 .
-
" '
' '
• , - - - - - - - - - - - - - - - - - - -T- - - - - - - - I
l T '
'
§
'
l
8/2 o! I
' i . . . - ÷ . f........÷÷÷
' '
' l
G
s
g i
¥ 812018£
i
"
l
' o !
l
8/2
F i l i
•
i l ' i
t
' ←% → ← s b→ ←
Py =
7 9 6 8 5 4 3 11 2 I
spy =
9 6 8 4 3
← 8. → ← 8 →
I
;
s i l '
i
CAN 2 POINTS
• i . - - - - - - i -' - - - - - - - - - - - - I - - - - - - - - l . '
1 N SAME
'
B G E
2 ,
' ' I
µ
•
!
' ,
! i.a. ! Box?."
'
. . . .@ . - - - - - - - - - - - - - - I - - - - -'
i
,
,
i
i, i
,
l
l ! o i ,
'
'
5 '
4 .
-
" '
' '
• , - - - - - - - - - - - - - - - - - - -T- - - - - - - - I
l T '
'
§
'
l
8/2 o! I
' i . . . -÷...f........÷÷÷
' '
' l
G
s
g i
¥
i
I
l
' o !
l
8/2
7 i l i
i l ' i
t
%→←sb→←slz→£s£
•
' ←
Py =
7 9 6 8 5 4 3 11 2 I
spy =
9 6 8 4 3
← 8. → ← 8 →
I
;
s i l '
i
CAN 2 POINTS
• i . ------I-------------I--------l.
! ! SAME
z i
b a t LIE IN
•
!
' ,
! i.a. ! Box?."
'
. . . .@ . - - - - - - - - - - - - - - I '- - - - - '
dla,b)⇐ 5M¥42
. i
, l
'
i .
i
i
I , o
I
'
-5281
5 '
4 .
-
• ! . . . . . ' -----÷-------÷. - . . . . . -i
' '
'
8
' T 4
i
Sk o! I
8
' i . . . -÷...f......-÷.----÷'t
' l
c l =
f
Fr
s
g i
.
i
I
l
' o !
l
8/2
7 i l i
i l ' i
t
%→←sb→←s1z→£s£
•
' ←
Py =
7 9 6 8 5 4 3 11 2 I
Sy
=
9 6 8 4 3
← 8. → ← 8 →
/
;
l
¥E\5AM
s i '
' --------l.
i
CAN 2 POINTS
• i .- - - - - - i - - - - - - - - - - - - -
! ! I boo'd
E
z
•
I
' ,
I !.a ! Box?."
'
. . . .@ . - - - - - - - - - - - - - - I '- - - - - '
dla.DE#FtCk)2
. i
, l
'
i ,
i
i
I , o
I
'
-5281
5 '
4 .
-
• ! . . . . . ' -----÷-------÷. - . . . . . -i
' '
'
8
' T 4
i
Sk o! I
8
' i . . . -÷...f......-÷.----÷'t
' l
c l =
f
Fr
s
g i
.
i
I
l
' o !
l
8/2
7 i l i
i l ' i
t
%→←sb→←s1z→£s£
•
' ←
Py =
7 9 6 8 5 4 3 11 2 I
Sy
=
9 6 8 4 3
← 8. → ← 8 →
-÷----
;
'
1 '
,
'
I
,
• i .- - - - - - i - - - - - - - - - - - - -
' --------l.
' '
' '
' ' l
2 , ,
l
I i
'i....? f.....
• ,
' '
I l
i
-÷----i, c
i
l
l ! o i ,
'
'
5 '
4 .
-
" '
' '
• , - - - - - - - - - - - - - - - - - - -T- - - - - - - - I
l T '
'
§
'
l
8/2 o! I
' i . . . - ÷ . f........÷÷÷
' '
' l
G
s
g i
¥
i
"
l
' o !
l
8/2
F i l i
• ,
i l '
I .
i
t
←
812→ ← 812→ ←
s1z→-Sb-
Py =
7 9 6 8 5 4 3 11 2 I
Sy
=
9 6 8 4 3
← 8. → ← 8 →
-÷----
;
'
1 i '
i
,
• i .- - - - - - i - - - - - - - - - - - - -
' --------l.
' '
' '
' ' l
2 , ,
l
I t
'i....? f.....
• ,
' '
I l
i
-÷----i, c
i
I
l ! o :
'
'
5 '
4 .
-
" '
' '
• , - - - - - - - - - - - - - - - - - - -T- - - - - - - - I
l T '
'
g
'
l
8/2 o! I
s
g i
.. 8 1 2 4 1 8 £
i
"
l
' o !
l
8/2
7 i l i
•
i l 1 '
' t
' ←% → ← s b→ ←
Py =
7 9 6 8 5 4 3 11 2 I
Sy
=
9 6 8 4 3
L
FIND ALL POINTS AT A D I S TA N C E 1 8
FROM LINE l .
← 8. → ← 8 →
----
;
'
1 i '
I
,
• i .- - - - - - i - - - - - - - - - - - - -
' --------l.
' "
' '
2 ; '
l
i ,
• I , i
' '
I l
f.....
'i....? -÷. -÷----i,
i c
i
l
l ! o i ,
'
'
5 '
4 .
-
" '
' '
• , - - - - - - - - - - - - - - - - - - -T- - - - - - - - I
l T '
'
§
'
l
8/2 o! I
s
g i
.. 8 1 2 0 148 £
i
'
l
3
'
2
o i
l
8/2
7 , l i
•
i l 1 '
' t
' ←% → ← s b→ ←
Py =
7 9 6 8 5 4 3 11 2 I
Sy
=
9 6 8 4 3
FIND ALL POINTS AT A D I S TA N C E 1 8
FROM LINE l .
← 8. → ← 8 →
----
;
'
1 i '
I
,
• i .- - - - - - i - - - - - - - - - - - - -
' --------l.
' "
' '
2 ; '
l
i ,
• I , i
' '
I l
f.....
'i....? -÷. -÷----i,
i c
i
l
l ! o i ,
'
'
5 '
4 .
-
" '
' '
• , - - - - - - - - - - - - - - - - - - - T - - - - . . . - i
' T '
' 5 '8
'
l
G 8/2 o! '
s
g i
.. 8 1 2 0 148 £
i
'
l
3
'
2
o i
l
8/2
7 , l i
•
i l 1 '
' t
' ←% → ← s b→ ←
Py =
7 9 6 8 5 4 3 11 2 I
Sy
=
9 6 8 4 3
FIND ALL POINTS AT A D I S TA N C E 1 8
FROM LINE l .
← 8. → ← 8 →
----
;
'
1 i '
i
,
• i .- - - - - - i - - - - - - - - - - - - -
' --------l.
' '
' '
' ' l
2 , ,
l
• I , t
' '
I l
f.....
'i....? -÷. -÷----i,
i c
i
l
l ! o i ,
'
'
5 '
4 .
-
" '
' '
• , - - - - - - - - - - - - - - - - - - - T - - - - . . . - i
' T'
' 5 8
'
l
G Sk o! '
8 f
' i . . . -÷...f........÷÷÷
' '
c l
f
s
g i
¥ 8 1 2 4 148 £
i
'
l
3
'
2
o i
l
8/2
7 , l i
•
i l 1 '
' t
' ←% → ← s b→ ←
Py =
7 9 6 8 5 4 3 11 2 I
Sy
=
9 6 8 4 3
FIND ALL POINTS AT A D I S TA N C E 1 8
FROM LINE l .
← 8. → ← 8 →
-÷----
;
'
1 '
,
'
I
,
• i .- - - - - - i - - - - - - - - - - - - -
' --------l.
' '
' '
' ' l
2
13
, ,
'
i
14 '
'i....? f.....
'
•
' ' 15 I 16 l
i
-÷----i, c
i
9
'
l ! i
10
.
1 11 1 2 1
5 ,
q .
-
' '
' '
• , - - - - - - - - - - - - - - - - - - - T - - - - . . . - i
' T '
' 5 8
'
l
G Sk o! '
8 f
' i . . . - ÷ . f........÷÷÷
' '
c l
f
s
g i
¥
i
'
l
3 4
'
2
o i
l
8/2
7 , l i
i l 1 '
' t
%→←sb→←s1z→£s£
•
' ←
Py =
7 9 6 8 5 4 3 11 2 I
Sy
=
9 6 8 4 3
I 2 3 4 5 6 7 8 9 10 11 12 13 14 1 5 16
9 X
Sy: X X X 6 8 X X 4 X X X 3 X X
FIND ALL POINTS AT A D I S TA N C E 1 8
FROM LINE l .
← 8. → ← 8 →
----
;
'
1 i '
i
,
• i .- - - - - - i - - - - - - - - - - - - -
' --------l.
' '
' '
' ' l
2
13
, ,
'
• i
' ' 14 15
'
I 16
'
l
f.....
'i....? -÷. -÷----i,
i c
i
9
'
l ! i
10
.
1 Il 1 2 1
5 .
q .
-
' '
' '
• , - - - - - - - - - - - - - - - - - - - T - - - - . . . - i
' T '
' 5 8
'
l
G Sk o! '
8 f
' i . . . -÷...f........÷÷÷
' '
c l
f
s
g i
¥
i
'
l
3 4
'
2
o i
l
8/2
7 , l i
i l 1 '
' t
• , I .
←
812-← 812→ ←
s1z→-Sb-
Py =
7 9 6 8 5 4 3 11 2 I
Sy
=
9 6 8 4 3
I 2 3 4 5 6 7 8 9 10 11 12 13 14 1 5 16
9 X
Sy: X X X 6 8 X X 4 X X X 3 X X
Q: How
many
block to the
right o f 9
yo u have
to check?
FIND ALL POINTS AT A D I S TA N C E 1 8
FROM LINE l .
← 8. → ← 8 →
-÷----
;
'
1 i '
i
,
• i .- - - - - - i - - - - - - - - - - - - -
' --------l.
' '
' '
' ' l
2
13
, ,
'
i
14 '
'i....? f.....
'
•
' ' 15 I 16 l
i
-÷----i, c
i
9
'
l ! i
10
.
1 11 1 2 1
5 ,
q .
-
' '
' '
• , - - - - - - - - - - - - - - - - - - - T - - - - . . . - i
' T'
' 5 8
'
l
G Sk o! '
8 f
' i . . . - ÷ . f........÷÷÷
' '
c l
f
s
g i
¥
i
'
l
3
'
4 2
o i
l
8/2
7 , l i
i l 1 '
' t
%→←sb→←s1z→£%''
•
' ←
Py =
7 9 6 8 5 4 3 11 2 I
Sy
=
9 6 8 4 3
I 2 3 4 5 6 7 8 9 10 11 12 13 14 1 5 16
9 X
Sy: X X X 6 8 X X 4 X X X 3 X X
Q: How
many
block to the
right o f 9
yo u have
to check?
A: At most 1 2
FIND ALL POINTS AT A D I S TA N C E 1 8
FROM LINE l .
← 8. → ← 8 →
----
;
'
1 i '
i
,
• i .- - - - - - i - - - - - - - - - - - - -
' --------l.
' '
' '
' ' l
2
13
, ,
'
• i
' ' 14 15
'
I 16
'
l
f.....
'i....? -÷. -÷----i,
i c
i
9
'
l ! i
10
.
1 Il 1 2 1
5 .
q .
-
' '
' '
• , - - - - - - - - - - - - - - - - - - - T - - - - . . . - i
' T '
' 5 8
'
l
G Sk o! '
8 f
' i . . . - ÷ . f........÷÷÷
' '
c l
f
s
g i
¥
i
'
l
3 4
'
2
o i
l
8/2
7 , l i
i l 1 '
' t
%→←sb→←s1z→£s£
•
' ←
Py =
7 9 6 8 5 4 3 11 2 I
Sy
=
9 6 8 4 3
£ 5 6 9 13
I 2 3 4 5 6 7 8 9 10 11 12 13 14 1 5 16
Sg: 9 X X X 6 8 X X 4 X X X 3 X X X
Q: How
many
block to the
right o f 9
yo u have
to check?
A: At most 1 2
ELSE
CLOSEST PAIR (Pr,Py)
{ I F I Put € 3
ELSE
{ CONSTRUCT Q u , Dy, R a , Rg 1 N OLD
TIME
(901%2) ← CLOSEST P A I R (du, @y)
s = min { d l q o . g l , dtrom))
CLOSEST PAIR (Pr,Py)
{ I F I Put € 3
ELSE
{ CONSTRUCT Q u , Dy, R a , Ry I N O N
TIME
(901%2) ← CLOSEST P A I R (du, @y)
s = min { d l q o . g l , dtrom))
I ← M a x N - C O O R D I N AT E I N @x
L ←
day) : next}.
CONSTRUCT Sy I N Oln) TIME
m i n e s :
FOREACH S E Sy
{ COMPUTE T H E D I S TA N C E FROM
s f 1 2 POINTS TO
THE RIGHT o f s in 8g
LET 6,5) B E THE PAIR WHICH
ACHENES THE MINIMUM
If dlsis') < m i n
] m i n ← desist)
y
-
3 RETURN m i n
Ofnlogn)
Closest Pair (p%yj INITIAL
{ I F I Put € 3
BASE [ BRUTE FORCE FIND T H E C LO S E S T PAIR
CASE
,
047 ELSE
{ CONSTRUCT Q n , Oy, R n , Ry I N O N
TIME
(nz)
1- [(901 ← CLOSEST P A I R (du, @y)
(z) %2)
from) CLOSEST PA I R (Ra,Ry)
←
1-
{ dlqo.gr), dtrom))
omfg:*:*'s
s = min
I ← M a x N - C O O R D I N AT E I N @x
'
,':# 'on,
✓
m i n e s ;
-time
FOREACH S E Sy
{ COMPUTE T H E D I S TA N C E FROM
TO THE LEFT
s f 10 POINTS
4 RIGHT o f s in 8g
L E T 6,5) B E THE PAIR WHICH
ACHENES THE MINIMUM
If dlsis') < m i n
] m i n ← desist)
}
-
3 RETURN m i n
Ofnlogn)
Closest Pair (p%yj INITIAL
{ I F I Put € 3
BASE [ BRUTE FORCE FIND T H E C LO S E S T PAIR
CASE
,
047 ELSE
{ CONSTRUCT Q n , Oy, R n , Ry I N O N
TIME
(nz)
1- [(901 ← CLOSEST P A I R (du, @y)
(z) %2)
from) CLOSEST PA I R (Ra,Ry)
←
1-
{ dlqo.gr), dtrom))
¢:*:*'s;÷:'
s = min
I ← M a x N - C O O R D I N AT E I N @se
oin,
on
-time
✓
m i n e s ;
FOREACH Sy
(
S E
{ COMPUTE T H E D I S TA N C E FROM
" *
sq Fagin
II."s",}g""
'
an)
LET 6,5) B E THE PAIR WHICH
ACHENES THE MINIMUM
If dlsis') < m i n
] m i n ← desist)
}
-
3 RETURN m i n
Initialization =
Olnlogn)
Tin) = 2 T
(z) t o n
TG) = C
INITIALIZATION =
Olnlogn)
Tin) = 2 T
(z) t o n
TG) = c
Tc h ) =
Olnlogn).
Greatest Overlap Problem
8 1 2
• • #
I a
• - •
6 g
o I
o o 7 - 10
#
14
I a
• - •
6 g
o n
7 10 14
°
o f #
if b s c
Find overlap between Laib] of kid]
Assume a < c
if b s c
return 0
else if b E d
return
Find overlap between Laib] of kid]
Assume a < c
if b < c
return 0
else if b E d
return b -c
else
Find overlap between Laib] of kid]
Assume a < c
if b s c
return 0
else if b e d
return b -c
else d -c
if b s c
return 0
else if b e d
return b -c
else d -c
if b s c
return 0
else if b e d
return b -c
else d -c
if b s c
return 0
else if b e d
return b -c
else d -c
3 . 13
#
O 4 11 14
# T o
8 1 2
=
6 10
o n =
11.5 16
Sort the intervals their starting position
by
Left ; Right
2 1 9 1 5
7
# ' I
'
3 . 13
t o
0 4 11 14
I
l =
& 1 2
#
G '
10
• # =
I 11.5 16
I
Sort the intervals their starting position
by
Left ; Right
2 1 9 1 5
7
'
# I
'
B 13
I
•
0 4 11 14
I
l =
of 1 2
E A
p
(
G '
l o
e a t . - .
I 11.5 n 16
Find t h e greatest
'
)
overlap f o r left Find t h e greatest
intervals overlap f o r
sight intervals
Sort the intervals their starting position
by
Left ; Right
2 1 9 1 5
7
'
# I
'
B 13
I
•
0 4 11 14
I
l =
of 1 2
E A
p
(
G '
l o
e a t . - .
I 11.5 n 16
Find t h e greatest
'
)
overlap f o r left Find t h e greatest
intervals overlap f o r
sight intervals
0 4 11 14
I
l =
of 1 2
E A
p
(
G '
l o
e a t . - .
I 11.5 n 16
Find t h e greatest
'
)
overlap f o r left Find t h e greatest
intervals overlap f o r
sight intervals
¥7::#
0 4 11 14
I
1 #
of 1 2
#
¥ i
0 4 11 14
I
l =
of 1 2
#
: : #
§>
¥:X::#
0 = 4 I
z ' ¥ 4
of 1 2
#
:[21€,
'
B 13
I
•
(ou:
0 = 4
8 1 2
#
=
.
(
16
! 11.5
¥7::#
0 4 11 14
I
l =
of 1 2
#
¥ i
0 4 11 14
I
l =
of 1 2
#
: : #
¢¥::#
0 4 11 14
I
l =
of 1 2
#
overlap1 I i ,I z , . . . - I n )
{ if n - I
return
sort intervals using their starting position
overlap1 I i ,Iz,...,In)
{ if n - I
return 0 ;
sort intervals using their starting position
overlap1 I i ,I z , . . . ,I n )
{ if n - I
return 0 ;
overlap1 I i ,I z , . . . - I n )
{ if n - I
return 0 ;
T ← interval in I i , Iz,..., I n k w i t h
maximum endpoint
sort intervals using their starting position
overlap1 I i ,I z , . . . ,I n )
{ if n - I
return 0 ;
T ← interval in I i , Iz,..., I n k w i t h
endpoint
maximum
greatestoverlap- m a x hoi,023
foreach (enteryal T i n I n k . t l , . . . . In)
{
sort intervals using their starting position
overlap1 I i ,I z , . . . ,I n )
{ if n - I
return 0 ;
I ← interval in I i , Iz,..., I n k w i t h
maximum endpoint
greatest-overlap- max {01,023
foreach (enteryal T i n I n k . t l , . . . . In)
{
O ←
overlap between I@J
greatest-overlap ← max {greatest-overlap,
} o}
return greatest-overlap
}
sort intervals using their starting position
Tln)
\
Overlap1 I i ,I z , . . . ,I n )
{ if
return
n - I
0 ;
} Old
(2) {Oz
1- overlapl I,,.... Ink)
←
Oz ←
overlap (Inzti,.....I n )
I ← interval in I i , Iz,..., I n k w i t h
maximum endpoint
greatest-overlap- max {01,023
foreach (enteryal T i n I n k . t l , . . . . In)
{
O ←
overlap between I f J
greatest-overlap ← m a x
{greatest-overlap,
} o}
return greatest-overlap
}
sort intervals using their starting position
Tln)
\
Overlap1 I i ,Iz,...,In)
{ if
return
n - I
0 ;
} Old
(2) {Oz
1- overlapl I,,.... Ink)
←
Oz ←
overlap (Inga,.....I n )
§:&:
I ← interval in I i , Iz,..., I n k w i t h
-
maximum endpoint
'
min'÷÷÷.....
'iii.
c:#iii. }
O ←
overlap
greatest-overlap ←
between
max
I@J
{greatest-overlap,
o}
return greatest-overlap
}
Rn) 2 T
(2)
=
t o n
TG) = c .
sort intervals using their starting position
Tln)
\
Overlap1 I i ,Iz,...,In)
{ if
return
n - I
0 ;
} Old
(2) {01
1- overlapl I,,.... Ink)
←
Oz ←
overlap (Inga,.....I n )
{site:
I ← interval in I i , Iz,..., I n k w i t h
-
maximum endpoint
' min'"÷÷÷......tn,
'iii.
c:#iii. }
O ←
overlap
greatest-overlap ←
between
max
I@J
{greatest-overlap,
o}
return greatest-overlap
}
Rn) Tbs)-Olnlogn)
2 T
(2)
-
t o n
T(D= c .