Big O Annotation
cs-fundamentals
Big O Annotation
In computer science, Big O notation O(1), O(n) is used to describe the performance or time complexity of an algorithm.- i.e how the performance scaled as the amount of data grows.
Common Big-O complexities
- O(1) -> constant time.
Does n't depend on the size of the data. Example
list.get(5) // Accessing element by the index in ArrayList
- O(n) → Linear time.
Performance grows proportionally with data size. Example:
for (int x : list) { ... } // Loop through n elements