Saturday, 13 February 2016

Algorithm Analysis

Algorithms are used to solve problems.
There may be different ways to solve an instance of a problem.
And this brings the challenge to compare the algorithms against each other.

A program is an algorithm which is encoded into some programming language.
This means we can have many programs for the same algorithms depending upon the programmer and the programming language used. It is easier and more meaningful to compare the algorithms when the problem size is large.

The two factors which can help to find efficient algorithm are space and time complexity.
Space complexity is to use the resources efficiently or use less resources.

Time complexity talks about the running time of an algorithm.
But this again depends upon the computer clock speed, the operating system, platform, the programming language and other factors.

To overcome this, Big O notation is used which ignores the other factors like computational speed and programming language. It only considers the number of steps taken/done to solve the problem. Like the number of assignment operations done. Big O is also called order of magnitude.

When the performance varies with the size of the program, we say algorithm has performance of O(n).

However, when the performance is dependent on the value of the data and not on the size of problem, then we measure the performance in Worst case, Best case scenarios and calculate Average cases.

Github Link: https://github.com/SmushBall/Algo

No comments:

Post a Comment