Simple Explanation of Big O Notation

The simplest definition I can give for Big-O notation is this:

Big-O notation is a relative representation of the complexity of an algorithm.

There are some important and deliberately chosen words in that sentence:

  • relative: you can only compare apples to apples. You can't compare an algorithm to do arithmetic multiplication to an algorithm that sorts a list of integers. But two algorithms that do arithmetic operations (one multiplication, one addition) will tell you something meaningful;
  • representation: Big-O (in its simplest form) reduces the comparison between algorithms to a single variable. That variable is chosen based on observations or assumptions. For example, sorting algorithms are typically compared based on comparison operations (comparing two nodes to determine their relative ordering). This assumes that comparison is expensive. But what if comparison is cheap but swapping is expensive? It changes the comparison; and
  • complexity: if it takes me one second to sort 10,000 elements how long will it take me to sort one million? Complexity in this instance is a relative measure to something else.

Come back and reread the above when you've read the rest.

The best example of Big-O I can think of is doing arithmetic. Take two numbers (123456 and 789012). The basic arithmetic operations we learnt in school were:

  • addition;
  • subtraction;
  • multiplication; and
  • division.

Each of these is an operation or a problem. A method of solving these is called an algorithm.

Addition is the simplest. You line the numbers up (to the right) and add the digits in a column writing the last number of that addition in the result. The 'tens' part of that number is carried over to the next column.

Let's assume that the addition of these numbers is the most expensive operation in this algorithm. It stands to reason that to add these two numbers together we have to add together 6 digits (and possibly carry a 7th). If we add two 100 digit numbers together we have to do 100 additions. If we add two 10,000 digit numbers we have to do 10,000 additions.

See the pattern? The complexity (being the number of operations) is directly proportional to the number of digits n in the larger number. We call this O(n) or linear complexity.

Subtraction is similar (except you may need to borrow instead of carry).

Multiplication is different. You line the numbers up, take the first digit in the bottom number and multiply it in turn against each digit in the top number and so on through each digit. So to multiply our two 6 digit numbers we must do 36 multiplications. We may need to do as many as 10 or 11 column adds to get the end result too.

If we have two 100-digit numbers we need to do 10,000 multiplications and 200 adds. For two one million digit numbers we need to do one trillion (1012) multiplications and two million adds.

As the algorithm scales with n-squared, this is O(n2) or quadratic complexity. This is a good time to introduce another important concept:

We only care about the most significant portion of complexity.

The astute may have realized that we could express the number of operations as: n2  2n. But as you saw from our example with two numbers of a million digits apiece, the second term (2n) becomes insignificant (accounting for 0.0002% of the total operations by that stage).

The Telephone Book

The next best example I can think of is the telephone book, normally called the White Pages or similar but it'll vary from country to country. But I'm talking about the one that lists people by surname and then initials or first name, possibly address and then telephone numbers.

Now if you were instructing a computer to look up the phone number for "John Smith" in a telephone book that contains 1,000,000 names, what would you do? Ignoring the fact that you could guess how far in the S's started (let's assume you can't), what would you do?

A typical implementation might be to open up to the middle, take the 500,000th and compare it to "Smith". If it happens to be "Smith, John", we just got real lucky. Far more likely is that "John Smith" will be before or after that name. If it's after we then divide the last half of the phone book in half and repeat. If it's before then we divide the first half of the phone book in half and repeat. And so on.

This is called a binary search and is used every day in programming whether you realize it or not.


One of the best, down-to-Earth explanations of a concept that can get incredibly complex.

Folksonomies: computer science algorithms

/science/mathematics/arithmetic (0.675960)
/science/mathematics/algebra (0.283286)
/business and industrial (0.257408)

digit numbers (0.999272 (negative:-0.360656)), telephone book (0.741536 (positive:0.405890)), deliberately chosen words (0.729673 (positive:0.388814)), complexity (0.700598 (positive:0.266816)), Big-O notation (0.679245 (positive:0.452227)), arithmetic operations (0.674429 (neutral:0.000000)), algorithm (0.662353 (negative:-0.155599)), best example (0.660140 (positive:0.435314)), basic arithmetic operations (0.659255 (neutral:0.000000)), John Smith (0.586456 (neutral:0.000000)), phone book (0.577269 (negative:-0.696352)), addition (0.511454 (negative:-0.010409)), arithmetic multiplication (0.506557 (neutral:0.000000)), simplest definition (0.498893 (positive:0.637638)), linear complexity (0.492601 (neutral:0.000000)), comparison (0.492351 (negative:-0.744425)), Simple Explanation (0.491697 (positive:0.525307)), down-to-Earth explanations (0.490934 (positive:0.707263)), simplest form (0.484893 (positive:0.402641)), Big O Notation (0.483893 (positive:0.525307)), relative representation (0.480132 (positive:0.266816)), quadratic complexity (0.475716 (neutral:0.000000)), relative measure (0.465808 (neutral:0.000000)), digits (0.458999 (positive:0.023599)), single variable (0.458154 (neutral:0.000000)), algorithm scales (0.449414 (neutral:0.000000)), comparison operations (0.446297 (neutral:0.000000)), expensive operation (0.444853 (negative:-0.458750)), 100-digit numbers (0.442806 (neutral:0.000000)), good time (0.441254 (positive:0.830003))

John Smith:Person (0.731210 (neutral:0.000000)), two one million digit:Quantity (0.731210 (neutral:0.000000)), two 10,000 digit:Quantity (0.731210 (neutral:0.000000)), million digits:Quantity (0.731210 (neutral:0.000000)), two 100 digit:Quantity (0.731210 (neutral:0.000000)), two 100-digit:Quantity (0.731210 (neutral:0.000000)), two 6 digit:Quantity (0.731210 (neutral:0.000000)), one second:Quantity (0.731210 (neutral:0.000000)), 6 digits:Quantity (0.731210 (neutral:0.000000)), 0.0002%:Quantity (0.731210 (neutral:0.000000))

Multiplication (0.965264): dbpedia | freebase
Addition (0.962888): dbpedia | freebase
Elementary arithmetic (0.923354): dbpedia | freebase
Number (0.844205): dbpedia | freebase
Arithmetic (0.834060): dbpedia | freebase | opencyc
Big O notation (0.775516): dbpedia | freebase
Algorithm (0.769925): dbpedia | freebase | opencyc
Telephone (0.765331): dbpedia | freebase | opencyc

 Plain English explanation of Big O
Electronic/World Wide Web>Message Posted to Online Forum/Discussion Group:  Unknown, (01/19/2013), Plain English explanation of Big O, Retrieved on 2013-05-29
  • Source Material []
  • Folksonomies: complexity algorithms


    29 MAY 2013

     Big O Continued

    Simple Explanation of Big O Notation > Place/Position > Simple Explanation of Big O Part II
    Linking the two memes into one complete explanation.
    Folksonomies: continuation
    Folksonomies: continuation