Sobes.tech
Senior

What is Big O notation?

sobes.tech AI

Answer from AI

Big O notation is a way of describing the asymptotic complexity of an algorithm, that is, estimating its performance or resource consumption (time, memory) depending on the size of the input data.

It shows how quickly the execution time or the amount of memory used grows as the input size increases, ignoring constants and less significant terms.

For example:

  • O(1) — constant time, does not depend on the size of the data.
  • O(n) — time proportional to the size of the input.
  • O(n²) — time proportional to the square of the input size.

Big O helps compare algorithms and choose the most efficient ones for large data volumes.

Example: if you have a function that iterates through an array of n elements once, its complexity is O(n). If there is a nested loop over the same array inside, the complexity will be O(n²).

What is Big O notation? — Golang - sobes.tech