## What is Time Complexity

Time complexity estimates how an algorithm performs, regardless of the programming language and processor used to run the algorithm. We can calculate time complexity simply by counting the number of statements (especially loops and recursive calls) executed by the code written. This time complexity is defined as a function of the input size *n*. Usually, we use Big-Oh notation to represent the worst-case time complexity of the algorithm.

## What is Asymptotic Complexity Classes

As time complexity is the function of input size *n*. These functions are used to represent the behavior of the algorithm if the input size increases to a very large number.

There are majorly five types of Complexity Classes:

- Constant Functions
- Decreasing Functions
- Polynomial Functions
- Logarithmic Functions
- Exponential Functions

## Constant Functions

A constant function is a function whose (output) value is the same for every input value.

Example: 1, 10, 50, 1000, 10000, 100000,... *(Any positive numerical value)*

## Decreasing Functions

Decreasing function value decreases if the value of input *"n"* increases.

Example: $\frac{1}{n},\frac{1}{{n}^{2}},\frac{\mathrm{log}n}{n},\frac{n}{{2}^{n}},...$

## Polynomial Functions

A polynomial function is a function that involves only non-negative integer powers. Polynomial functions are usually in the form of *n ^{C}, where C is a positive non-zero integer (C>0)*.

Example: *n ^{0.1}, n^{0.5}, n^{2.5}, n^{50}, n^{10000}*,...

- Linear Function:
*n* - Quadric Function:
*n*^{2} - Cubic Function:
*n*^{3}

## Logarithmic Functions

Example: log(n), (log(n))^{2}, log(n))^{10},...

## Exponential Functions

In Exponential functions, the value of function increases drastically if the input value increases. Exponential functions are usually in the form of C^{n}*, where C is a positive non-zero integer (C>1)*.

Example: 2^{n}, 3^{n}, (1.5)^{n}, 7^{n},...

The below graph is representing the complexity classes in *time* vs *input value.*

## Comparison of values of Asymptotic Complexity Classes

Decreasing Functions **<** Constant Function **<** Logarithmic Functions **<** Polynomial Functions **<** Exponential Functions

Here are some examples of Complexity classes comparisons:

- 2
^{n}<n^{n} - 2
^{n}<n! - n! < n
^{n} - $\mathrm{log}\left(n\right)<\sqrt{n}$
- (log(n))
^{2}< n - (log(n))
^{3}< n - (log(n))
^{1000}< n - (log(n))
^{log(n)}> n

**Ques**: Consider one more example with four functions given below and write in increasing order.

F_{1 }= 10

F_{2} = $\sqrt{n}$

F_{3} = log(n)

F_{4} = $\frac{100}{n}$

**Sol**: Increasing order for the given functions is F_{4} < F_{1} < F_{3} < F_{2}

*We will see more examples with explanations in the next article.*