Growth matters
Big O describes how cost grows
Big O focuses on the relationship between input size and resource use. Constants still matter in real systems, but growth tells you which solution will stop scaling first.
Doubling an input barely changes logarithmic work, doubles linear work, and roughly quadruples quadratic work.

Read the structure
Loops do not automatically mean O(n)
A loop that halves the remaining search space is logarithmic. Two independent loops add their costs. Nested loops often multiply them, but only when both ranges grow with the input.
def binary_search(values, target):
left, right = 0, len(values) - 1
while left <= right:
mid = (left + right) // 2
if values[mid] == target:
return mid
if values[mid] < target:
left = mid + 1
else:
right = mid - 1
return -1 # O(log n)
Count memory too
Auxiliary space can change the best choice
Space complexity includes additional storage created by the algorithm. A recursive call stack, copied slice, hash map, or dynamic-programming table can dominate memory.
State whether you are counting the output itself. Interviewers often ask for auxiliary space separately.
- Count growing collections
- Include recursion depth
- Notice copied inputs and substrings
- Separate output space from working space
Continue learning
Build the complete mental model with the visual lessons, examples, and practice material in the DSA with C++ course.
Explore the course