In an algorithm with time complexity of O(n2), if the number of inputs has doubled, what trend does the execution time increase?
2)'sFrom this
(2n)2 = 4n2
22Is this four times the answer?
I keep getting confused between unchanged and 4x.
I'm confused with the part where you throw away the coefficient of the highest port when you make the Big O notationㅠ<
data-structure time-complexity big-o
In O(n2), n2 represents the highest order of magnitude of T(n) in the worst case scenario. where n is the number of data.
22I think the number of inputs in the question means the number of data n, right?
The approximate computation from Big O is n2, and if the original number of data was x, the computation would be x2 if the number of data was doubled to 2x, the computation would be (2x)2=4x2.
2222Eventually, x2 became 4x2, so the running time is quadrupled.
22However, the sentence of the question seems to be misleading. If the question asks for a change in execution time, I think it will be right that there is no change in Big O because the "change in execution time" is big, and if the question is just asking for an increase in "execution time" itself, it will be four times right.
© 2024 OneMinuteCode. All rights reserved.