nxn - city university of new yorksaad/courses/alg/algorithms...growth of functions so far: 1.5...

14
Divide & Conquer for nxn matrix a I -7 , if ' iii. = f÷ii¥ . iii. et f G H R = EE t BI S = AI t BI T = U = Tcn ) = f 8TH ) + an ' n > , C n = I

Upload: others

Post on 25-Dec-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: nxn - City University of New Yorksaad/courses/alg/Algorithms...Growth of functions So far: 1.5 n't 3.5N-2 = ⑦( n ') nlogn t n =-0 (nlogn) Asymptotic efficiency: what happens when

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

Page 2: nxn - City University of New Yorksaad/courses/alg/Algorithms...Growth of functions So far: 1.5 n't 3.5N-2 = ⑦( n ') nlogn t n =-0 (nlogn) Asymptotic efficiency: what happens when

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)

Page 3: nxn - City University of New Yorksaad/courses/alg/Algorithms...Growth of functions So far: 1.5 n't 3.5N-2 = ⑦( n ') nlogn t n =-0 (nlogn) Asymptotic efficiency: what happens when

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 . . . - ]

Page 4: nxn - City University of New Yorksaad/courses/alg/Algorithms...Growth of functions So far: 1.5 n't 3.5N-2 = ⑦( n ') nlogn t n =-0 (nlogn) Asymptotic efficiency: what happens when

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

Page 5: nxn - City University of New Yorksaad/courses/alg/Algorithms...Growth of functions So far: 1.5 n't 3.5N-2 = ⑦( n ') nlogn t n =-0 (nlogn) Asymptotic efficiency: what happens when

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

Page 6: nxn - City University of New Yorksaad/courses/alg/Algorithms...Growth of functions So far: 1.5 n't 3.5N-2 = ⑦( n ') nlogn t n =-0 (nlogn) Asymptotic efficiency: what happens when

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

Page 7: nxn - City University of New Yorksaad/courses/alg/Algorithms...Growth of functions So far: 1.5 n't 3.5N-2 = ⑦( n ') nlogn t n =-0 (nlogn) Asymptotic efficiency: what happens when

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

Page 8: nxn - City University of New Yorksaad/courses/alg/Algorithms...Growth of functions So far: 1.5 n't 3.5N-2 = ⑦( n ') nlogn t n =-0 (nlogn) Asymptotic efficiency: what happens when

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

Page 9: nxn - City University of New Yorksaad/courses/alg/Algorithms...Growth of functions So far: 1.5 n't 3.5N-2 = ⑦( n ') nlogn t n =-0 (nlogn) Asymptotic efficiency: what happens when

Example functions in R ( n' )n' n'+ n n

'- n ( n'- n > In" for largen)

n'

- loon n'log n

Page 10: nxn - City University of New Yorksaad/courses/alg/Algorithms...Growth of functions So far: 1.5 n't 3.5N-2 = ⑦( n ') nlogn t n =-0 (nlogn) Asymptotic efficiency: what happens when

① - 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

Page 11: nxn - City University of New Yorksaad/courses/alg/Algorithms...Growth of functions So far: 1.5 n't 3.5N-2 = ⑦( n ') nlogn t n =-0 (nlogn) Asymptotic efficiency: what happens when

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)

Page 12: nxn - City University of New Yorksaad/courses/alg/Algorithms...Growth of functions So far: 1.5 n't 3.5N-2 = ⑦( n ') nlogn t n =-0 (nlogn) Asymptotic efficiency: what happens when

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

Page 13: nxn - City University of New Yorksaad/courses/alg/Algorithms...Growth of functions So far: 1.5 n't 3.5N-2 = ⑦( n ') nlogn t n =-0 (nlogn) Asymptotic efficiency: what happens when

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

Page 14: nxn - City University of New Yorksaad/courses/alg/Algorithms...Growth of functions So far: 1.5 n't 3.5N-2 = ⑦( n ') nlogn t n =-0 (nlogn) Asymptotic efficiency: what happens when

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