0

An algorithm takes 1 second to execute a dataset of size N on a particular computer. Replace it with a computer that is 10 times faster. What will be the size of the dataset you can process in 1 second on the new computer if the execution time for a dataset of size n is proportional to n^2?

I am having a hard time wrapping my head around this question. I think that if the machine is 10 times faster, it should be able to execute 10 times the amount of data. This means it could do a data set of size 10N. But wouldn't this only be if the execution time was proportional to n? If the execution time grows quadratic as the input grows, wouldn't the dataset have to be less than 10N?

  • 2
    Forget the two computers. If the target computer is 10 times faster than the one first mentioned, then processing N targets takes 0.1s on it. The question then becomes: for O(n^2), how fast can n grow so that processing time increases tenfold? The answer is the inverse of the term in the Big-O class. – Kilian Foth Sep 21 '18 at 15:04
  • Another way to think about it is like this: whatever N takes 10s to execute on the slow computer will take 1s on the fast computer (same number of instructions in both cases (ideally speaking), it just executes 10 times faster). So, on the slow computer, you have 1s ~ N^2. Just multiply that by 10, and then rearrange the right side so that it's in the form 10s ~ (something)^2. That is, pull whatever is outside the square back under it. The 'something' in the parentheses is your new N. – Filip Milovanović Sep 21 '18 at 21:28

1 Answers1

2

Well theta-O complexity can thought of as how many discrete operations must be performed to reach the final state. So if it has O(n^2) complexity then it performs at most n^2 operations. Complexity has nothing to do with the speed itself of the computer. In fact it is only loosely related to computation speed. It just means how much work the computer has to do to reach the result.

The speed of a computer has to do with how many discrete operations it can perform per second. Since you want to know what N you would select to perform 10 discrete operations, try asking, "what N would increase the overall number of operations by 10?" the answer would be the square root of 10.