I am given the amount of data and the time used. It asks for the time complexity. It is in a Big-O packet
Below is the first problem given

Algorithm A
Data     Time
1000     .003
2000     .012
4000     .048
8000     .192

Please explain how to get the time complexity. Thanks!

5 Years
Discussion Span
Last Post by gotto

Of course not. You'll need to think a little bit and infer the big O notation out of it. For example, if the time doubles along with the data, that's O(N). If it squares each time, that's O(N^2).


And if it is between O(n) and O(n^2), you can use O(nlogn)... But watch out for O(cn) because it is the same as O(n)...

Edited by Taywin


Thanks. Now on the last one there is not a pattern of increasing. Data is the same, but the time is: .0030, .0066, .0142, .3256

I even went into how much it could multiply by to get the next time.


That would be very simple. Think as the data is n, and the time is whatever the increment type is. That will be your answer.

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.