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:
Note: We ignore small terms and constants.
For example, 2n² + 3n + 100 becomes just n² 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 c such that:
f(n) is less than or equal to c*g(n) when n is large.
Don't worry too much about the formula. Just remember:
Big-O tells us the slowest speed the program might run.
Summary:
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.