time-space trade-off the best algorithm to solve particular problem at hand is no doubt the one that requires less memory space and takes less time to complete its execution but practicallydesigning such an ideal algorithm is not trivial task there can be more than one algorithm to solve particular problem one may require less memory spacewhile the other may require less cpu time to execute thusit is not uncommon to sacrifice one thing for the other hencethere exists time-space trade-off among algorithms soif space is big constraintthen one might choose program that takes less space at the cost of more cpu time on the contraryif time is major constraintthen one might choose program that takes minimum time to execute at the cost of more space expressing time and space complexity the time and space complexity can be expressed using function (nwhere is the input size for given instance of the problem being solved expressing the complexity is required when we want to predict the rate of growth of complexity as the input size of the problem increases there are multiple algorithms that find solution to given problem and we need to find the algorithm that is most efficient the most widely used notation to express this function (nis the big notation it provides the upper bound for the complexity algorithm efficiency if function is linear (without any loops or recursions)the efficiency of that algorithm or the running time of that algorithm can be given as the number of instructions it contains howeverif an algorithm contains loopsthen the efficiency of that algorithm may vary depending on the number of loops and the running time of each loop in the algorithm let us consider different cases in which loops determine the efficiency of an algorithm linear loops to calculate the efficiency of an algorithm that has single loopwe need to first determine the number of times the statements in the loop will be executed this is because the number of iterations is directly proportional to the loop factor greater the loop factormore is the number of iterations for exampleconsider the loop given belowfor( = ; < ; ++statement blockhere is the loop factor we have already said that efficiency is directly proportional to the number of iterations hencethe general formula in the case of linear loops may be given as (nn however calculating efficiency is not as simple as is shown in the above example consider the loop given belowfor( = ; < ; += statement blockherethe number of iterations is half the number of the loop factor sohere the efficiency can be given as (nn/