Complexity
Complexity is the process of comparing a minimum of 2 algorithms with respect to space and time. Complexity also measures how much more time and space are required as the input of said algorithms grows in size.
An algorithm is said to be efficient and fast if it takes less time to execute and consumes less memory space.
Types of Complexity
There are six types of complexity:
- Constant Complexity
[O(1)]
- Logarithmic Complexity
[O(log n)]
- Linear Complexity
[O(n)]
- Quadratic Complexity
[O(n^2)]
- Factorial Complexity
[O(n!)]
- Exponential Complexity
[O(2^n)]
To measure complexity, there are two steps:
- Space Complexity
- Time Complexity