lecture20

lecture20 - COMPSCI 102 Introduction to Discrete...

Info iconThis preview shows pages 1–17. Sign up to view the full content.

View Full Document Right Arrow Icon
COMPSCI 102 Introduction to Discrete Mathematics
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is The Big Oh! Lecture 20 (November 15, 2010)
Background image of page 2
* * * * * * * * * * * * * * * * * * * * * * + How to add 2 n-bit numbers
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
* * * * * * * * * * * * * * * * * * * * * * * * + How to add 2 n-bit numbers
Background image of page 4
* * * * * * * * * * * * * * * * * * * * * * * * * * + How to add 2 n-bit numbers
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
* * * * * * * * * * * * * * * * * * * * * * * * * * * * + How to add 2 n-bit numbers
Background image of page 6
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + How to add 2 n-bit numbers
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * * “Grade school addition” How to add 2 n-bit numbers
Background image of page 8
+ T(n) = amount of time grade school addition uses to add two n -bit numbers * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * Time complexity of grade school addition What do we mean by “time”?
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Our Goal We want to define “ time ” in a way that transcends implementation details and allows us to make assertions about grade school addition in a very general yet useful way.
Background image of page 10
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 ???
Background image of page 11

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
On any reasonable computer, adding 3 bits and writing down the two bit answer can be done in constant time Pick any particular computer M and define c to be the time it takes to perform on that computer. Total time to add two n -bit numbers using grade school addition: cn [ c time for each of n columns]
Background image of page 12
On another computer M’ , the time to perform may be c’. Total time to add two n -bit numbers using grade school addition: c’n [ c’ time for each of n columns]
Background image of page 13

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
The fact that we get a line is invariant under changes of implementations. Different machines result in different slopes, but time grows linearly as input size increases . # of bits in the numbers t i m e M a c h i n e :
Background image of page 14
Thus we arrive at an implementation independent insight: Grade School Addition is a linear time algorithm This process of abstracting away details and determining the rate of resource usage in terms of the problem size n is one of the fundamental ideas in computer science.
Background image of page 15

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
For any algorithm, define Input Size = # of bits to specify its inputs. Define
Background image of page 16
Image of page 17
This is the end of the preview. Sign up to access the rest of the document.

Page1 / 53

lecture20 - COMPSCI 102 Introduction to Discrete...

This preview shows document pages 1 - 17. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online