# Time Complexity and Space Complexity

For most students, it is very hard to find the Time complexity and space complexity of a problem. Time complexity doesn't mean, the time taken to for the program to run. In layman's terms, Time Complexity means, it tells us how time grows when the input of the program grows. there are three types of Time Complexities.

# `TIME COMPLEXITY != TIME TAKEN`

***Big-OH Notation***: Generally, In layman's terms, This gives the <mark>upper bound</mark> of time complexity i.e, the algorithm will not exceed the given time complexity, but It may execute in lesser time, but will not exceed the given time complexity. This is used to find worst-case complexity.

*0 &lt;= f(n) &lt;= Cg(n) for all n &gt;= n0*

Big-OH Notation Graph:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1673034068833/0bb7a558-96c6-458a-9fd2-fc8f5275892c.png align="center")

2. ***Big-Omega Notation***: This is the exact opposite of Big-OH notation, this gives the minimum time complexity i.e, the algorithm will at least take this time to execute and it may also take more than this time complexity. *0 &lt;= Cg(n) &lt;= f(n) for all n &gt;= n0*
    

Big-Omega Notation Graph:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1673034185617/c582e091-ddc1-47ff-b9a1-c563ed8cf946.png align="center")

3.Theta Notation: in the layman's terms, This is the combination of both Big-oh and Big-Omega Notation . it gives the tightest bound and it is best of all the worst cases times that the algorithm can take.

**Mathematically,** 

0 &lt;= f(n) &lt;= C1g(n) for n &gt;= n0  
0 &lt;= C2g(n) &lt;= f(n) for n &gt;= n0

**Merging both the equation, we get :**  

0 &lt;= C2g(n) &lt;= f(n) &lt;= C1g(n) for n &gt;= n0

Theta Notation Graph:

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1673034499712/9f75d3e0-9735-45f0-8934-a37c9bbccfa8.png align="center")

These are important 3 Time complexities. I hope you understood the concepts generally. please refer correct definations for complete understanding.

NOTE: Given defination are not exact correct definations, those are just for understanding the concepts better.

Resources : Geeksforgeeks for images.
