Complexity curves
Now consider a problem of magnitude n. To determine the time complexity of an algorithm, we denote it with T(n). The value may fall under O(1), O(log n), O(n), O(n log(n)), O(n2), O(n3), or O(2n). Depending on the steps an algorithm performs, the time complexity may or may not be affected. The notation O(n) captures the growth rate of an algorithm.
Let's now examine a practical scenario. By which means do we arrive at the conclusion that the bubble sort algorithm is slower than the quick sort algorithm? Or in general, how do we measure the efficiency of one algorithm against the other? Well, we can compare the Big O of any number of algorithms to determine their efficiency. It is this approach that gives us a time measure ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access