Algorithm complexity (time/space) is the main evaluating factor for any algorithm. Here, time refers to the duration required to execute instructions/steps, while space refers to the space occupied by its data structure. Both are directly related to the performance of an algorithm.
When using an algorithm to resolve a problem in our application, search for the most efficient way to achieve that. This means we have to use an algorithm with minimal possible steps. If we already have an algorithm/logic, and need to optimize its performance, we first need to perform the following steps: