---
# System prepended metadata

title: Big O notation and Time Complexity
tags: [Algorithm]

---

# Big O notation and Time Complexity

###### tags: `Algorithm`

Algorithm describe steps to accomplish a specific task.

When run an algorithm, usually there are 2 types of complexity:

- Memory complexity: Amount of memory it takes to run algorithm.
- Time complexity: Number of steps involved to run algorithm.

Big O notation describes the time complexity to run algorithm, by look at the worst case, and compare worst cases together.

When scale the algorithm, from the time complexity we will know how the algorithm will perform.

Actually, when dertemining time complexity of the algorithm, we're not doing math. What we try to do is get some sense of how number of steps grows as number of items we have to deal.

Below are a few of Big O Notation types

Speak: O of ...

- O(1): Constant (O of 1)
- O(logn): Logarithmic (base 2 of n) (O of Logarithmic ...)
- O(n): Linear
- O(nlogn): n log-star n
- O(n^2): Quadaric
