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!

Recommended Answers

All 7 Replies

As the data doubles, how does the time used scale? That's your complexity.

Would it be in a Big-O format though?

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)...

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.

Thanks. :)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.