You are on page 1of 5

6/17/22, 11:03 PM Difference between Big-O and Little-o Notations | Baeldung on Computer Science

(/cs/) (https://www.baeldung.com/cs/)

Difference between Big-O


and Little-o Notations
Last modified: August 23, 2021

by Akbar Karimi (https://www.baeldung.com/cs/author/akbarkarimi)

Algorithms (https://www.baeldung.com/cs/category/algorithms)
Core Concepts (https://www.baeldung.com/cs/category/core-
concepts)

If you have a few years of experience in Computer Science or


research, and you’re interested in sharing that experience with the
community, have a look at our Contribution Guidelines
(/cs/contribution-guidelines).

1. Overview
In this brief tutorial, we’ll learn about how big-O and little-o notations
differ. In short, they are both asymptotic notations that specify upper-
bounds for functions and running times of algorithms.
However, the difference is that big-O may be asymptotically tight while
little-o makes sure that the upper bound isn’t asymptotically tight.
Let’s read on to understand what exactly it means to be asymptotically
tight.

https://www.baeldung.com/cs/big-o-vs-little-o-notation 1/5
6/17/22, 11:03 PM Difference between Big-O and Little-o Notations | Baeldung on Computer Science

2. Mathematical Definition
Big-O and little-o notations have very similar definitions, and their
difference lies in how strict they are regarding the upper bound they
represent.

2.1. Big-O
For a given function , is defined as:
there exist positive constants and such that
for all .
So is a set of functions that are, after , smaller than or equal
to . The function’s behavior before is unimportant since big-O
notation (also little-o notation) analyzes the function for huge numbers.
As an example, let’s have a look at the following figure:

Here, is only one of the possible functions that belong to .


Before , is not always smaller than or equal to , but after , it
never goes above .
The equal sign in the definition represents the concept of
asymptotical tightness, meaning that when gets very large,
and grow at the same rate. For instance, satisfies the
equal sign, hence it is asymptotically tight, while is not.
https://www.baeldung.com/cs/big-o-vs-little-o-notation 2/5
6/17/22, 11:03 PM Difference between Big-O and Little-o Notations | Baeldung on Computer Science

For more explanation on this notation, look at an introduction to the


theory of big-O notation (/cs/big-o-notation).

2.2. Little-o
Little-o notation is used to denote an upper-bound that is not
asymptotically tight. It is formally defined as:
for any positive constant , there exists positive constant
such that for all .
Note that in this definition, the set of functions are strictly
smaller than , meaning that little-o notation is a stronger upper
bound than big-O notation. In other words, the little-o notation does not
allow the function to have the same growth rate as .
Intuitively, this means that as the approaches infinity, becomes
insignificant compared to . In mathematical terms:

In addition, the inequality in the definition of little-o should hold for any
constant , whereas for big-O, it is enough to find some that satisfies
the inequality.
If we drew an analogy (https://mitpress.mit.edu/books/introduction-
algorithms-third-edition) between asymptotic comparison of and
and the comparison of real numbers and , we would have
while .

3. Examples
Let’s have a look at some examples to make things clearer.
For , we have:
but
and
and
In general, for , we will have:
https://www.baeldung.com/cs/big-o-vs-little-o-notation 3/5
6/17/22, 11:03 PM Difference between Big-O and Little-o Notations | Baeldung on Computer Science

but
and
and
For more examples of big-O notation, see practical Java examples of the
big-O notation (/java-algorithm-complexity).

4. Conclusion
In this article, we learned the difference between big-O and little-o
notations and noted that little-o notation excludes the asymptotically
tight functions from the set of big-O functions.

If you have a few years of experience in Computer Science or


research, and you’re interested in sharing that experience with the
community, have a look at our Contribution Guidelines
(/cs/contribution-guidelines).

Comments are closed on this article!

CATEGORIES
ALGORITHMS (/CS/CATEGORY/ALGORITHMS)
ARTIFICIAL INTELLIGENCE (/CS/CATEGORY/AI)
CORE CONCEPTS (/CS/CATEGORY/CORE-CONCEPTS)
DATA STRUCTURES (/CS/CATEGORY/DATA-STRUCTURES)
GRAPH THEORY (/CS/CATEGORY/GRAPH-THEORY)
LATEX (/CS/CATEGORY/LATEX)
NETWORKING (/CS/CATEGORY/NETWORKING)
SECURITY (/CS/CATEGORY/SECURITY)

https://www.baeldung.com/cs/big-o-vs-little-o-notation 4/5
6/17/22, 11:03 PM Difference between Big-O and Little-o Notations | Baeldung on Computer Science

SERIES
DRAWING CHARTS IN LATEX (/CS/CATEGORY/SERIES)

ABOUT
ABOUT BAELDUNG (HTTPS://WWW.BAELDUNG.COM/ABOUT)
THE FULL ARCHIVE (/CS/FULL_ARCHIVE)
WRITE FOR BAELDUNG (/CS/CONTRIBUTION-GUIDELINES)
EDITORS (HTTPS://WWW.BAELDUNG.COM/EDITORS)

TERMS OF SERVICE (HTTPS://WWW.BAELDUNG.COM/TERMS-OF-SERVICE)


PRIVACY POLICY (HTTPS://WWW.BAELDUNG.COM/PRIVACY-POLICY)
COMPANY INFO (HTTPS://WWW.BAELDUNG.COM/BAELDUNG-COMPANY-INFO)
CONTACT (/CONTACT)

https://www.baeldung.com/cs/big-o-vs-little-o-notation 5/5

You might also like