Docsity

Big O Notation and Time Complexity in Discrete Mathematics, Slides of Discrete Mathematics

Partial preview of the text

Download Big O Notation and Time Complexity in Discrete Mathematics and more Slides Discrete Mathematics in PDF only on Docsity!

Introduction to Discrete

Ma th e m a tic s

This is The Big Oh!

Ho w to a d d 2 n -b it nu m b e rs

Ho w to a d d 2 n -b it nu m b e rs

Ho w to a d d 2 n -b it nu m b e rs

“Gra d e s c h o o l a d d itio n ”

Ho w to a d d 2 n -b it nu m b e rs

Our Goal We wa n t to d e fin e “tim e ” in a wa y th a t tra n s c e nd s im p le m e n ta tio n d e ta ils a n d a llo ws u s to m a ke a s s e r tio n s a b o u t g ra d e s c h o ol a d d itio n in a ve r y ge n e ra l ye t u s e fu l wa y.

  • A given algorithm will take different amounts of time on the same inputs depending on such factors as: » Processor speed » Instruction set » Disk speed » Brand of compiler

Roadblock ???

On another computer M’, th e tim e to p e r fo r m m a y b e c ’.

To ta l tim e to a d d two n -b it nu m b e rs u s in g g ra d e s c h o o l a d d itio n :

c ’n [c ’ tim e fo r e a c h o f n c o lu m ns ]

The fact that we get a line is inva r ia nt u n d e r c h a n ge s o f im p le m e n ta tio ns. Diffe re n t m a c h in e s re s u lt in d iffe re n t s lo p e s , b u t tim e g ro ws lin e a rly a s in p u t s ize in c re a s e s.

o f b its in th e nu m b e rs

t i m e

Time vs Input Size

Fo r a n y a lgo r ith m , d e fin e In p u t S ize = # o f b its to s p e c ify its in p u ts.

De fin e TIME (^) n = th e wo rs t-c a s e a m o u n t o f tim e u s e d o n in p u ts o f s ize n

We o fte n a s k: Wh a t is th e g ro wth ra te o f Tim e (^) n?

X

n 2

Ho w to mu ltip ly 2 n -b it nu m b e rs.

of bits in the numbers

t i m e

Gra d e S c h o o l Ad d itio n : Lin e a r tim e Gra d e S c h o o l Mu ltip lic a tio n : Qu a d ra tic tim e

No m a tte r h o w d ra m a tic th e d iffe re n c e in th e c o n s ta n ts , th e q u a d ra tic c u rve will e ve n tua lly d o m in a te th e lin e a r c u rve

How much time does it take to square the nu m b e r N u s in g g ra d e s c h o o l mu ltip lic a tio n?