The performance of an algorithm is generally measured by the size of its input data (n) and the time and the memory space used by the algorithm. Time required is measured by the key operations to be performed by the algorithm (such as comparison operations), whereas the space requirements of an algorithm is measured by the storage needed to store the variables, constants, and instructions during the execution of the program. The space requirements of an algorithm may also change dynamically during execution as it depends on variable size, which is to be decided at runtime, such as dynamic memory allocation, memory stacks, and so on.
The running time required by an algorithm depends on the input size; as the input size (