What is it?

To compare the performance of any algorithm for the same application, one can compare the complexity of those algorithms.

In general, an algorithm is considered more efficient when it’s less complex.


Types of complexity

There are two types of algorithm complexity:

  • Size complexity

    Refers to the allocated memory required to run the algorithm. For example, the number and size of the variables. The data size is referred as .

  • Time complexity

    Refers to the number of needed instructions to run the algorithm. This is important because it’s directly related to the time it takes to run the algorithm.


Big-O Notation

The most widely used way of comparing the complexity of different algorithms is the Big-O Notation.

The Big-O Notation refers to the possible worst case of the execution, and it’s related to time complexity, specifying the number of operations it’ll perform on each data point.