Professional Documents
Culture Documents
Lecture 02 , 08/25/2021
Master 's theorem :
1 if net
1- In) =
# sub
a :
problems
Mb : size of input of each subproblem
D- Ind) :
running time of the combining step .
TIM = a. Tlnlb ) -1 nd
dtnd
(F) d) + a
Told not 7
+
i
=
nd .
5¥ (g),
geometricser.ie#
a=bd
nd.lk#)- nd.lwgY-&+ijF=--g-n,.1fasbddclogba
d-
If logba
Tim -
)=O- ( nd ¥109bn)
k
Tla )=O- ( nd .
-9¥
If asbd .
d >
1098 combining step dominates .
TIM = Qlnd ) .
( hd D= logba
① logy if
{
'
Tin)=0-
lntogn ) .
selectionproblem-7-nputiar ayA-4.mn ] , integer K ,
I a- Ken .
output : the K -
th smallest number in A .
specials :
k=m , k=n/2.1 median )
Goat design that 0-1 a) time
: a DIF algo runs in .
Exampte A-
[41-912,4%+7-310] K=6
:
= ,
based
pi partition
4¥ ☒ TEA 2
selection ] K)
function ( ALT n
.
. .
if n=t .
return All ] .
|
✗ c-
find pivot 1A K) -
,
Az
partition A into Ai × .
.
Ai =
{ a c- At a < ×
}
Az =
{ ac- At a> × }
, mum µ ,# on , , , µ
µ µ , , ,, ,
else K > 1A / ,
+ I return selection / Ask-1A , / -
D
.
ead
correctness .
Runningtime
:
Let Tlnl be the running time of
selection ( A , K) when IAI =
n .
twine median
using median of medians
" "
V5
¥É;;¥f#;y
sub
arrays
A:
M
t.IE:1 1Mt 45
:
|
.
1m44 Toys)
end
Fact :
1AM 7 F- It 7-0×2
✗
=
¥ .
11+43 F- ✗ É -1,10×2 =
3%
=act 1AM = n -
IAH -1 £
7%
1174 = n -
1AM -
£7,10
I
fÉÉ;÷§ TIM
TIM
5-+8--9-07
=
=
01M
① In .
log n ) .
if atb < 1
TIM =
0-1^1 .
find -
medians takes
* 49 ¥
"
✗ = =
¥ .
1 All , LAY f n
-
¥ =
3¥ .
maxflA.li/A4} a-
3¥ Tln) -0cm -1T¥) -1113¥)
too +
E- =
to a 0-1^1 .
2. size of sub
array
=
3
TIM =
D- In) (F) 1- 1- ( Max { 1AM /AaB )
1- 1- ,
.
1AM .
1174 a-
Is I + f- I -9--31
✗ ✗ =
1AM , 1174 3 n -
-4=231
TIM = D- In) 1- 1- (F) -1T¥)
-3+-32--1 TIM =
Olnlogn) .
comparison of size =
5 vs size =
100
log
100 .
,÷
in all sub
arrays =
logs
-
N
=