t i m e of bits T n The amount of time grade school addition uses to add two n bit numbers What do you mean by time Processor speed Instruction set Disk speed Brand of compiler 0 1 2 Hold on You just admitted that it makes no sense to measure the time T n taken by the method of grade school addition since the time depends on the implementation details We will have to speak of the time taken by a particular implementation as opposed to the time taken by the method in the abstract Don t jump to conclusions Your objections are serious but not insurmountable There is a very nice sense in which we can analyze grade school addition without ever having to worry about implementation details Here is how it works On any reasonable computer adding 3 bits and writing down the two bit answer can be done in constant time Pick any particular computer A 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 Implemented on another computer B the running time will be c n where c is the time it takes to perform on that computer Total time to add two n bit numbers using grade school addition c n c time for each of n columns t i m e a M e n i ch cn A M c n B ne achi of bits in numbers 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 Thus we arrive at an implementation independent insight Grade School Addition is a linear time algorithm Determining the growth rate of the resource curve as the problem size increases is one of the fundamental ideas of computer science Abstr ac tion Abstr ac t away the inessential featur es of a pr oblem or solution I see We can define away the details of the world that we do not wish to currently study in order to recognize the similarities between seemingly different things TIME vs INPUT SIZE For any algorithm define INPUT SIZE of bits to specify inputs Define TIMEn the worst case amount of time used on inputs of size n We Often Ask What is the GROWTH RATE of Timen X n2 How to multiply 2 n bit numbers X n2 I get it The total time is bounded by cn2 0 03 t i m e of bits in numbers 4 5 Ok so How much time does it take to square the number n using grade school multiplication 0 3 t i m e of bits in numbers 6 7 5 t i m e of bits used to describe input 1 6 7 1 6 7 Worst case Time T n for algorithm A means that we define a measure of input size n and we define T n MAXall permissible inputs X of size n running time of algorithm A on X 1 t i m e of bits used to describe input 1 1 6 7 0 1 4 2 3 Thus Nursery School adding and multiplication are exponential time They SCALE HORRIBLY as input size grows Grade school methods scale polynomially just linear and quadratic Thus we can add and multiply fairly large numbers Multiplication is efficient what about reverse multiplication Let s define FACTORING n to any method to produce a nontrivial factor of n or to assert that n is prime 8 4 9 6 6 7 7 66 7 7 6 6 7 7 4 2A B 4 24 6 7 We know methods of FACTORING that are sub exponential about 2cube root of k but nothing efficient 8 6 7 6 7 0 C 0 6 7 D f O n means that there is a line that can be drawn that stays above f from some point on t i m e of bits in numbers 8 6 7 6 7 0 C 0 6 7 D f n means that there is a line that can be drawn that stays below f from some point on t i m e of bits in numbers 8 6 7 6 7 6 7 0 6 7 f n means that f can be sandwiched between two lines t i m e of bits in numbers 8 6 7 6 7 0 C 0 6 7 E 6 7 D 8 6 7 6 7 0 C 0 6 7 F 6 7 D 8 6 7 6 7 6 7 0 6 7 n O n2 YES n O sqrt n NO 3n2 4n O n2 YES 3n2 4n n2 YES n2 nlogn YES n2logn NO n2 3 4 3 8 6 7 6 7 6 7 6 7 6 7 6 G7 B 6 7 6 7 0 6 7 G 2 4 8 2 2 6 7 0 6 7 6 7 6G 7 2 6 7 4 8 2 B 4 6 7 6 0 6 7 6 7 7 0 6 7 6 6 77 H 9 9 2 2 6 7 I I6 7 I6 7 I 6 7 I 6 7 I6 7 I 6G7 J I 6 7 J GJ I 6 7 K L6 M 7 I6 7 I6 7 I6 7 I 6 7 I 6 7 I6 7 I 6G7 J I 6 7 J GJ I 6 7 K L6 7 L6 7 L6 7 L6 J 7 G L6J GJ 7 L6 7 6 L6 4 2 B B B 7 7 2 8 2 6 6 6 H 8 7 N O 7 6 7 O 7 6 6 77 6 7 F M 6 7 H O 6 6 6 7 N O 7 6 7 O 7 6 6 77 O H6 7 6 7 H B 0 n inverse Ackermann n 4n L 6 7 P Q 2 J 6G70GJ GR R K G 9 S92 2 T H U T n The amount of time grade school addition uses to add two n bit numbers We saw that T n was linear X n2 T n The amount of time grade school multiplication uses to add two n bit numbers We saw that T n was quadratic 0 03 t i m e of bits in numbers 4 5 Neat We have demonstrated that as things scale multiplication is a harder problem than addition Mathematical confirmation of our common sense Don t jump to conclusions We have argued that grade school multiplication uses more time than grade school addition This is a comparison of the complexity of two algorithms To argue that multiplication is an inherently harder problem than addition we would have to show that the best addition algorithm is faster than the best multiplication algorithm Grade school addition is linear time Is there a sub linear time for addition Suppose there is a mystery algorithm A that does not …
View Full Document
Unlocking...