Skip to content

Time Complexity

Time complexity measures how execution time grows relative to input size n.


ComplexityMeaningExample
O(1)Constant time, doesn’t depend on input sizeAccess array element
O(log n)Input halves each stepBinary Search
O(n)Runs once per elementLinear search
O(n log n)Divide and merge type algorithmsMerge Sort, Quick Sort
O(n²)Nested loopsBubble Sort
O(2ⁿ)Exponential growthRecursive subsets