Big Oh (O) Notation

Big-O Notation is a way to describe the maximum time an algorithm might take to complete its task, especially when the input is very large.

Big Oh (O) Notation

Big Oh (O) Notation

Published by: Anil K. Panta

What is Big Oh Notation?

Big-O Notation is a way to describe the maximum time an algorithm might take to complete its task, especially when the input is very large.

This helps programmers understand the slowest performance of their program — also called the worst-case scenario.

Example in Real Life:

Imagine you are looking for your name in a list of students:

  • If your name is at the top, you find it quickly (Best Case).

  • But if your name is at the bottom, you have to check every name (Worst Case).
    Big-O notation shows this worst-case time.

Why is Big-O important?

  • Helps compare algorithms

  • Shows how programs grow with bigger data

  • Doesn’t depend on actual computer or language

  • Saves time during coding and testing

How to Use Big-O:

Let’s look at some examples to understand Big-O better:

Function / Code

Big-O Notation

Meaning

100log(2000)10,000

O(1)

Constant time – super fast

n/42n+3n + log(n)

O(n)

Grows slowly with input

n² + n, 2n²n² + log(n)

O(n²)

Grows faster – takes more time

Note: We ignore small terms and constants.
 For example, 2n² + 3n + 100 becomes just  in Big-O.

Mathematical Rule:

If f(n) is the actual time taken by a program, then
 f(n) = O(g(n)) means 
there’s a constant number such that:
 f(n) is less than or equal to c*g(n) when is large.

Don't worry too much about the formula. Just remember:
Big-O tells us the slowest speed the program might run.

Summary:

Concept

Simple Meaning

Big-O Notation

Shows the worst-case time of an algorithm

Why it’s useful

Helps you choose the fastest and best algorithm

What it ignores

Small details and fixed numbers

When it’s used

When input becomes very large

Example

Bubble Sort is O(n²), Linear Search is O(n)

Final Thoughts:

Big-O notation helps programmers and students like you understand how fast or slow a program will run when given large inputs.
It’s a powerful tool to write better, faster, and smarter code.

We will get back to you via email or phone call