With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

No credit card required

The Role of Big O

Despite the fact that Big O doesn’t distinguish between Bubble Sort and Selection Sort, it is still very important, because it serves as a great way to classify the long-term growth rate of algorithms. That is, for some amount of data, O(N) will be always be faster than O(N2). And this is true no matter whether the O(N) is really O(2N) or even O(100N) under the hood. It is a fact that there is some amount of data at which even O(100N) will become faster than O(N2). (We’ve seen essentially the same concept in Chapter 3, Oh Yes! Big O Notation when comparing a 100-step algorithm with O(N), but we’ll reiterate it here in our current context.)

Look at the first graph, in which we compare O(N) with O(N2).

We’ve seen this graph ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

No credit card required