Member-only story
Big-O notation, easiest way to learn it?(DSA Part— 2.1)
Big-O is a mathematical way to describe the efficiency of an algorithm in terms of time or space.
As the input size grows, It focuses on the upper bound of the growth rate, meaning it tells you the worst-case scenario for how the algorithm will perform.
My articles are open for everyone; non-member readers can read the article by clicking this Friend link.
Other DSA Links: DSA Part — 0 | DSA Part — 1 | DSA Part — 2 | DSA Part — 2.1 | DSA Part 2.2 | DSA Part 3 | DSA Part 4 | DSA Part 5 | DSA Part — 6
In simpler terms, it answers questions like:
- How will the runtime increase if the input size doubles or triples?
- How much memory will this algorithm use as the input grows?
Why Focus on the Upper Bound?
Algorithms often behave differently depending on the input. For example:
- Best-case: The input is already sorted, so your sorting algorithm finishes quickly.
- Average-case: The input is in random order, so the algorithm performs moderately.
- Worst-case: The input is in the exact reverse order, requiring the maximum number of steps.
Big-O notation focuses on the…