1- A certain algorithm takes twice as long to process 1000n elements as it does to process n elements. Give a possible time complexity for this algorithm and a specific value of n
2- A certain O(nlogn) algorithm is always used in practice over an available O((logn)^2) algorithm
Assuming they meant "for all n", the answer is definitely not quadratic. The runtime doubles, but only when the input size multiplies by one thousand! If it were quadratic, the runtime would double when the input size multiplies by 1.414. Just find the ration of n^2 to (1.414n)^2.
Generally, we have the relationship: f(1000n) = 2 f(n). What functions fit that relationship?
It grows a lot slower than quadratic. This means that the function is in O(n^2). But it also happens to be in O(n), and some even smaller bounds. (For being in O(n^2) means that the function grows no faster than n^2. If f(x) = x, then f(x) is in O(x^2).)
One function that fits the first equation is f(n) = n^(0.010034333189).
If that relationship they gave only applies to a specific value of n, and not all values of n, well, then you could fit almost any type of function to those two data points. You could let f(n) = 2^n. Then at the point n = 1/999, it would be true that f(1000n) = 2 f(n), and it would not be true anywhere else.
I don't know if this is all very relevant to your exam, but that's my take on the first question.
The second is not even a question or problem, it's just a statement of fact. Is it a true/false?
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Previous Thread in Computer Science Forum Timeline:complexity-2