It is the process of estimating the time and space needed to execution of an algorithm when is is written in pseudo code.
A common formula cannot be obtained for all the algorithms since an algorithm which is good for one kind of input can be time taking and worthless for a diffrent kind of inputs. For example if an input is an array of size 'n' we wud say that the size of the input is "n" but when we take a two dimensional array say of size "mxn" then the whole perspective of the analysis has changed and now the size is defined by two parametres m and n.
Among all the inputs of size 'n', we can ask for the max time needed for te algorithm to run. this time is called worst-case time for the algorithm. The average time needed for the algorithm to run for many "n"s is called average-case time.
since the primary goal is to estimate the time of the algorithm to execute not the exact time needed for an algorithm, we can count the number of steps of the algorithm then we will get an useful measure of time.
For example when we are adding something in a loop then we should count the number of repetitions, and will get the estimate of time.
No comments:
Post a Comment