Sitemap

Big-O notation

2 min readSep 6, 2025

--

Press enter or click to view image in full size

When we write code, it’s not just about making it work — we also care how it performs as the amount of data grows. Think of input as the number of items your program handles, like names in a list or products in a store. Understanding how your code scales helps you choose the right algorithms and avoid slow performance on large data.

1. O(1) time complexity — constant: The program takes the same amount of time no matter how many items there are. ex: checking the first name in a list. It doesn’t matter if the list has 10 names or 1,000 names, the time is always the same.

Get Razan Aboushi’s stories in your inbox

Join Medium for free to get updates from this writer.

2. O(log n) time complexity — logarithmic: the time grows very slowly even as the number of items increases. If you double the items, you only need one extra step to find your item. (like in binary search).

3. O(n) time complexity — linear: The time grows directly with the number of items. ex: checking each name in a list one by one. If the list has 10 names, it takes 10 steps → if it has 20 names, it takes 20 steps.

4. O(n²) time complexity — quadratic: The time grows very fast as the number of items increases here. ex: comparing every item with every other item (like bubble sort). If the list doubles, the number of comparisons becomes four times more.

Big-O helps you write efficient code, predict performance issues, and scale your applications. When working with large datasets, picking the right algorithm can make the difference between a program that runs in seconds and one that takes hours.

Originally published at https://www.linkedin.com.

--

--

Razan Aboushi
Razan Aboushi

Written by Razan Aboushi

Full Stack Developer | Software Engineer | Web Development | Performance Enhancement | UI/UX Design | React • Next.js • Node.js | PHP