Reverse String (In-Place & Two Pointers)
Asymptotic Complexity Masterclass

Big-O Complexity Visualizer & Cheat Sheet

Interactive Big-O asymptotic curve simulator and complexity reference table. Slide N to watch how constant, logarithmic, linear, quadratic, and exponential operations diverge at scale.

Production Ready
Interactive Input Scale Simulator (N = 10)
N = 10 elements
O(1)Constant
11 op
O(log N)Logarithmic
3.3log₂(10) ≈ 3.3 ops
O(N)Linear
1010 ops
O(N log N)Linearithmic
3310 × log₂(10) ≈ 33 ops
O(N²)Quadratic
10010² = 100 ops
O(2ᴺ)Exponential
1,0242^10 = 1,024 ops
O(N!)Factorial
3,628,80010! = 3,628,800 ops
Operations vs Elements Scale CurvesTime Complexity Horrible ➔ Excellent
O(1)O(log N)O(N)O(N log N)O(N²)O(2ᴺ)O(N!)N=10Elements (N) ➔Operations ➔
The 4 Golden Rules of Big-O Analysis
1

Rule 1: Always Consider Worst Case

When evaluating scalability, Big-O measures the asymptotic upper bound. For example, linear search in an array of N items might find the item at index 0 (Best Case: O(1)), but Big-O is strictly O(N) because in the worst case, the item is at the very end or missing entirely.

2

Rule 2: Remove Constants

Constant factors do not affect the rate of growth as N approaches infinity. O(2N) becomes O(N). O(100N + 500) becomes O(N). O(1 + N/2 + 100) becomes O(N). Whether a loop runs twice or once per item, its complexity is strictly linear.

3

Rule 3: Different Terms for Different Inputs

If an algorithm processes two distinct collections (e.g. array1 of size A and array2 of size B), nested loops result in O(A * B), NOT O(N²). Sequential loops over both arrays result in O(A + B), NOT O(N). Never conflate distinct input dimensions.

4

Rule 4: Drop Non-Dominant Terms

In multi-stage algorithms with combined polynomial terms, only the fastest-growing term matters at scale. O(N² + 5N + 100) simplifies to O(N²), because as N grows to 1,000,000, the N² term (10¹²) completely dwarfs 5N (5*10⁶).

Data Structure Time & Space Complexity Reference Table
Data StructureAccessSearchInsertionDeletionWorst Space
ArrayO(1)O(N)O(N)O(N)O(N)
Stack (LIFO)O(N)O(N)O(1)O(1)O(N)
Queue (FIFO)O(N)O(N)O(1)O(1)O(N)
Singly Linked ListO(N)O(N)O(1) at headO(1) at headO(N)
Doubly Linked ListO(N)O(N)O(1) at endsO(1) at endsO(N)
Hash TableN/AO(1) avgO(1) avgO(1) avgO(N)
Binary Search TreeO(log N) avgO(log N) avgO(log N) avgO(log N) avgO(N)
Sorting Algorithms Runtime & Space Benchmark
AlgorithmBest TimeAverage TimeWorst TimeWorst Space
Merge SortO(N log N)O(N log N)O(N log N)O(N)
Quick SortO(N log N)O(N log N)O(N²)O(log N)
Heap SortO(N log N)O(N log N)O(N log N)O(1)
Bubble SortO(N)O(N²)O(N²)O(1)
Insertion SortO(N)O(N²)O(N²)O(1)
Selection SortO(N²)O(N²)O(N²)O(1)
Big-O Time & Space Complexity Visualizer · DataArena