Why the analysis of algorithm?

To go from city ‘A’ to city ‘B’ there can be many ways of accomplishing this: by bus, train and also bt the bicycle. Depending upon the availability and convenience, we chose the one that suits us. Similarly, in computer science, multiple algorithms is available for solving a problem. Algorithm analysis helps us to determine which algorithm is most efficient in term of time and space consumed .

path between city A to B
Path between city A to B

The goal of analysis of algorithm is compare algorithms mainly in term of running time but also in terms of other factors (eg: memory, developer effort, etc.)

Running time analysis

It is the process of determining how processing time increase as the size of problem (input size) increases. Input size is the number of element in the input and depending on the problem type, the input may be of different types. The following types of inputs.

  • Size of an array
  • Polynomial degree
  • Number of element in a matrix
  • Number of bits in the binary representation of input
  • Vertices and edges in a graph

Comparison of algorithm

To compare algorithm, lets us define a few objective measures:

Execution times ? Not a good measure as execution times are specific to a particular computer.

Number of statement executed ? Not a good measure , since the number of statements varies with the programming language as well as the cycle of the individual programmer.

Ideal solution ? Let us assume that we express the running time of given algorithm as a function of the input size n (i.e.,f(n)) and compare these different functions corresponding to running times. This kind of comparison is independent of machine time, programming style.

Lets take example :

we need to boil eggs, we need following steps

  1. Take half of the water in cookware
  2. Take some egges.
  3. Put egges in cookware
  4. while(egges are boiled)
    1. closed the cookware
    2. fire up gasstove
  5. end

To analysis the above mentioned algorithm to cook eggs , we are calculate number of sets , total time take by computer to process this steps and memory consumption.

Hence, analysis of algorithm is important in machine learning to optimize the processing of data.

One thought on “Why the analysis of algorithm?

Leave a Reply

Your email address will not be published. Required fields are marked *