nxn - city university of new yorksaad/courses/alg/algorithms...growth of functions so far: 1.5...
TRANSCRIPT
Divide & Conquer for nxn matrix
a←I -7,
if'
iii. = f÷ii¥ . iii.etf G H
R = EE t BIS = AI t BIT =
U =
Tcn) = f8TH) + an
'
n > ,
C n = I
size tholesn Cn
"
- - - - - n Cn'd
1=80
n on; ⇐-2
. . . 4 -- - - -- -
2cm ' 8=8"
E, c¥¥¥ " .gg/#gng........4cn . 64=82
- ! I
÷ : :
i t!
I C - - - -- - - - -
- - - - -- e
. . . . . . ..
81% " c =Cn/%8= on }
gst£%"
. + on'
= cn2( It # thot - - -- - + 1) tons2-
=cn3( It It # + . . - -- ) =0Cn3)
Strassen ' alg improves on this by making
1-(n) = { 7TH) t an'
n > I
C h= I
c# in' + • a'% n
same as before largest term is n'927 = ne . 81
on' (4972 . ¥ + NILI I . . . . .) + on bit
=cubit (it 4g + ftp.jt . . . - ]
Strassen's Alg .
⇐ sit:B.ME:1FP, = A (G - H)Pa = (At B) H f- Rtp
" i.ie r.
By = D.(F - E) T=
Ps = ( AtD) •(Etf)U-po.io. Ftth(
ACE.¥III?¥ntBHPf = (A - C.)(Et G)AG TBH
Growth of functions-
So far : 1.5 n't 3.5N - 2 = ⑦ ( n')
nlogn t n = -0 (nlogn )
Asymptotic efficiency : what happens when n is very large .
- Ignore low- order terms
- drop constant factors
0-notah.cn
0(gcn)) = { f Cn) : 3 positive constants c and no such that
off Cn) f og Cn) for all n> no }
gcn) is an asymptotic upper bound on Faymurti"
±when we write fCn) = 0 (gas) what we mean is that
fat E Offend
Example : 2n'= C) (n') 0=1
, no =2
2n's 1. n'
for all n> 2
Example function in Ocn' ) .
n' n'th n 't 1000N nl . 9 not
log n
I - notation-
N (gcn)) = { f Cn ) : 3 positive constants c and no such that
of cgcnjsffn) for all n> no }
¥}cn, gcnlisannasyfmpytotic lower bound
Example: Tn = R ( Ign) ⇐ I no = 16
rn Z 1. logan for all n> 16
Example functions in R ( n' )n' n'+ n n
'- n ( n'- n > In" for largen)
n'
- loon n'log n
① - notation
⑦ (gcn)) = { fCn) : Z positive constants c. , Cz and no such that
of cigar) s fan) f czgcn) for all n> no}
↳#¥ gas is
.;Emtis# bound
Example : NI - 2n = ⑦ Cn ')
17€ n'
f I - 2n f DE n ' no=8gyTITTA STALAG
Transivityin far) = 0cg Cni) and gcntochcn))then Fcn) - F (had
this is true for O and R
Reflexivity f-G) = ⑦ (fat) , same for 0 and R
symmetry : fat = 0cg Cny ⇐ g Cnt offend
for 0(gas) ⇒ gcn) - READ
th) = OGGI)⇒ { fat - OGGIf-G) = rlgcns)
o - notation
ocgcn)) = { fan) : for all constants c > o , F a constant no > osuck that offcuts cgcn) for all n> no }
No no
honkingtg=o (zero)n
' -99= o (m2) Y÷ = off)
rife off) n'= 0(n')
w- notation : (symmetric ) try fg, = a
Abuse of notation
fcntocgcn)) fcnlsgcn)
ffitrcgcnl) flu) > gcn)
f-Cnt Ocgcnl) fan) - gcn)
f-Cn) -- ocgcns) fcnlsgcn)f-Cn ) - wcgcnl) fat > gcn)
Merge fort Insertion Selection sort-
a--
nlogn n na
nlogn = oCn2) n'# ocn')
nlogn=O( n') nzo-cn-ynt-ocnyn.ir
Two important facts : nb = o(a"
) a> i
FF. exponential
logarithmic, logbn =o(na) a > o
Some useful information about logarithms• log
,a=toscalogo b constant
so log,,a= D- ( log a)
• log n ! = En"
(it acts) (Stirling Approx)so log n! = Ocnlogn)
•alogb
=blog a
go 7- loosen = nb9e7= n' '81 . "
= o (ng