Carlos
Carlos

Reputation: 5455

When is Big-O = x classified as inefficient?

Lets say we have a problem we implemented using X algorithm with O(n) or O(log n) or etc.... When is the value of n big enough that we must consider an alternative implementation? Let's see if i can explain myself a little better.

For n=10,000

O(n^2) = 100,000,000

O(n) = 10,000

O(Log n) = 4

. . .

Obviously the best algorithm will be the one with the lowest "Big-o".

So lets say we sort an array of length 5 using bubble sort, the result is 25, that's not that bad. But when is the result of the O notation so large that realistically we must use another implementation.

Upvotes: 3

Views: 164

Answers (4)

Jan Gorzny
Jan Gorzny

Reputation: 1772

When it is equivalent to alt text and alpha = 1.

Upvotes: 0

JAL
JAL

Reputation: 21563

A solution too inefficient when there is another solution that is lower Big-O, and thus more efficient.

Upvotes: 0

Chris Heald
Chris Heald

Reputation: 62668

A certain Big O complexity doesn't mean that you should always avoid it; you should shoot for algorithms of lower complexities, but O(n^2) where n is 12 is going to run plenty fast regardless of the fact that O(n^2) is usually considered a "bad" complexity.

O(n^2) doesn't automatically mean "too slow"; O(n log n) doesn't automatically mean "yay, this is fast". If a given algorithm runs too slowly, then you want to reduce its runtime, and you can often do this by reducing its complexity, but until it becomes a problem, don't sweat it.

Upvotes: 1

Alex Budovski
Alex Budovski

Reputation: 18456

When it's a bottleneck in your application.

But in general, aim for algorithms with lowest complexity, while also allowing ease of implementation.

Upvotes: 4

Related Questions