“Don’t memorize the formulas. Understand why they exist.” π‘
π Introduction
If you’ve started learning Data Structures and Algorithms (DSA), you’ve probably heard terms like:
- Big-O Notation
- Big-Omega
- Big-Theta
- Asymptotic Analysis
Most students memorize these definitions because they appear in exams and interviews.
Unfortunately, this creates a big problem.
When someone asks:
Why do we use Asymptotic Notation?
or
Why do we ignore constants?
or
What exactly are T(n), f(n), c and nβ?
many students cannot answer.
The reason is simple.
Most books jump directly to mathematical formulas like this:
without explaining why this formula exists in the first place.
In this blog series, we’ll do something different.
Instead of memorizing formulas, we’ll first understand the purpose behind Asymptotic Notation.
Once you understand why it exists, the mathematical definitions become surprisingly simple.
π― What Will You Learn?
By the end of this series, you’ll understand:
β What Asymptotic Notation really means
β Why computer scientists invented it
β Why Big-O exists
β What T(n) actually represents
β What f(n) actually represents
β Why we ignore constants
β What c means
β What nβ means
β Why the mathematical definition is actually a proof, not a calculation method
π€ What is Asymptotic Notation?
Let’s begin with a simple question.
Suppose you write a Java program.
Now I ask you:
How fast is your program?
You might answer:
“It takes 2 milliseconds.”
Now I change the input size.
Instead of processing
10 records
I give you
10,000 records
Now your answer changes.
Maybe it takes
50 milliseconds
Now I increase the input again.
Instead of
10,000
I give you
10,000,000
Now the execution time may become
5 seconds
Notice something interesting.
The execution time keeps changing as the input size changes.
So instead of asking
“How many seconds does it take?”
Computer Scientists ask a different question.
“How does the running time grow as the input becomes larger?”
That question is answered using Asymptotic Notation.
π Definition
Asymptotic Notation is a mathematical notation used to describe how the running time or space requirement of an algorithm grows as the input size becomes very large.
Notice one important phrase.
“…as the input size becomes very large.”
That is the entire idea behind Asymptotic Analysis.
π€ What Does the Word “Asymptotic” Mean?
The word Asymptotic comes from Mathematics.
It refers to studying the behaviour of a function as it approaches infinity.
In Computer Science,
instead of studying
n = 5
or
n = 100
we imaginenββ
which simply means
The input size keeps increasing indefinitely.
π‘ Why Don’t We Care About Small Inputs?
Suppose two algorithms solve the same problem.
Algorithm A
Running TimeT(n)=5n+10
Algorithm B
Running TimeT(n)=200n+500
For
n = 10
Algorithm A performs60
operations.
Algorithm B performs2500
operations.
Algorithm B looks much slower.
Now suppose
n = 1,000,000
Algorithm A performs approximately5,000,010
operations.
Algorithm B performs approximately200,000,500
operations.
Although Algorithm B performs more operations, notice something.
Both algorithms grow linearly.
If the input doubles,
both running times approximately double.
Their growth pattern is identical.
That growth pattern is more important than the exact numbers.
π Real-Life Analogy
Imagine two cars.
π Car A travels at
60 km/hr
ποΈ Car B travels at
120 km/hr
One car is obviously faster.
But both cars travel at a constant speed.
If someone asks:
“What type of motion are these cars following?”
You would answer
Constant Speed Motion
You wouldn’t create separate categories called
- 60 km/hr Motion
- 120 km/hr Motion
because the pattern is the same.
Similarly,
Algorithms with5n
operations and500n
operations both belong to the same growth category.
That category isO(n)
π€ Why Was Asymptotic Notation Invented?
Imagine two programmers.
Both solve the same problem.
Programmer A
Uses Java.
Execution Time
2 seconds
Programmer B
Uses C++.
Execution Time
1 second
Which algorithm is better?
You can’t answer.
Why?
Because execution time depends on
- CPU
- RAM
- Programming Language
- Compiler
- Operating System
- Background Processes
These factors change from one computer to another.
Computer Scientists wanted a way to compare algorithms without depending on hardware.
Therefore,
instead of measuring seconds,
they measure growth.
π What Does Growth Mean?
Suppose
Algorithm A performs
10 operations
20 operations
40 operations
80 operations
Notice something?
Every time the input doubles,
the work also doubles.
This is called Linear Growth.
Now suppose another algorithm performs
10
100
1000
10000
Its growth is much faster.
Even if both algorithms are executed on the same computer,
their growth patterns are different.
That is exactly what Asymptotic Notation studies.
π€ Is Big-O the Same as Asymptotic Notation?
One of the biggest misconceptions among beginners is:
Big-O = Asymptotic Notation
This is not correct.
Big-O is only one type of Asymptotic Notation.
There are actually three major asymptotic notations.
| Notation | Purpose |
|---|---|
| Big-O (O) | Upper Bound |
| Big-Omega (Ξ©) | Lower Bound |
| Big-Theta (Ξ) | Tight Bound |
We’ll study each one in detail in the next parts.
π€ Before Learning Big-O, We Need to Understand One Important Thing
Suppose you analyzed a Java program and counted every operation.
You obtained3n+2
This expression represents the actual running time of your algorithm.
In algorithm analysis, we give it a special name.
We call itT(n)
π What is T(n)?
T(n) means
The actual running-time function of an algorithm.
It represents the exact number of operations (or an exact mathematical expression for those operations) as a function of the input size n.
For example,
Suppose we have this Java program.
for(int i = 0; i < n; i++)
{
System.out.println(i);
}
Earlier, we calculated:
Initialization1
Conditionn+1
Incrementn
Loop Bodyn
Therefore,T(n)=3n+2
Notice something important.
This is not Big-O.
This is simply the actual running-time expression.
π― Key Point
Whenever you count operations,
the result is calledT(n)
ExamplesT(n)=3n+2T(n)=5n2+7n+20T(n)=8logn+100
All of these are valid running-time functions.
π Part 1 Summary
Congratulations! π
In this part, we learned:
β What Asymptotic Notation is
β Why it was invented
β Why execution time is not a reliable measure
β Why we study algorithm growth
β The meaning of the word “Asymptotic”
β Why Big-O is only one Asymptotic Notation
β What T(n) represents
π Coming Up in Part 2
In the next part, we’ll answer the questions that confuse almost every DSA student:
- π€ What is f(n)?
- π€ Why do we ignore constants?
- π€ Why do we keep only the dominant term?
- π€ What is the difference between T(n) and f(n)?
- π€ Why do mathematicians write
0β€T(n)β€cβ f(n)
instead of simply writingT(n)=O(n)
We’ll also discover one of the biggest secrets behind Big-O:
The mathematical definition is not used to calculate Big-Oβit is used to prove that your Big-O answer is correct.
π‘ Final Thought
Before learning the mathematical formulas, always remember this:
Asymptotic Notation is not about measuring the exact running time of an algorithm. It is about understanding how the algorithm’s running time grows as the input size becomes extremely large.
Once you understand this idea, every asymptotic notationβBig-O, Big-Omega, and Big-Thetaβwill become much easier to learn. π