//

How to Compare Algorithms

We can compare algorithms based on the following method

Execution Time

We can compare algorithm based on the time it takes to execute some input. But the thing is the execution time is machine dependent.

No of statements executed

We can compare algorithm based on no of statement but it is also not a good measure because for different language the no of statement would be different for same algorithm. Also no of statements also depends on the code style of programmer.

Ideal Solution

So what we can do ideally is express the runtime of an algorithm as a function of input size n as f(n). Comparing algorithms like this is independent of machine time and programmer style.

Leave a Reply

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