Search⌘ K
AI Features

Big-O notation

Explore Big-O notation to learn how it represents an upper bound on the growth rate of algorithm running times. Understand its role in asymptotic analysis for assessing worst-case performance and why it is used alongside Big-Theta notation.

We'll cover the following...

We use big-Θ notation to asymptotically bound the growth of a running time to within constant factors above and below. Sometimes we want to bound from only above. For example, although the worst-case running time of binary search is Θ(lgn)\Theta(\lg{n}), it would be incorrect to say that binary search runs in Θ(lgn)\Theta(\lg{n}) time in all cases. What if we find the target value upon the first guess? Then it runs in Θ(1)\Theta(1) time. The running time of binary search is never worse than Θ(lgn)\Theta(\lg{n}), but it's sometimes better. It would be convenient to have a form of asymptotic notation that means "the running time grows at most this much, but it could grow more slowly." We use "big-O" notation for just such occasions.

If a running time is O(f(n))O(f(n)), then for large enough nn ...