Algorithms are often quite different from one another, though the objective of these algorithms are the same. For example, we know that a set of numbers can be sorted using different algorithms. Number of comparisons performed by one algorithm may vary with others for the same input. Hence, time complexity of those algorithms may differ. At the same time, we need to calculate the memory space required by each algorithm.
Analysis of algorithm is the process of analyzing the problem-solving capability of the algorithm in terms of the time and size required (the size of memory for storage while implementation). However, the main concern of analysis of algorithms is the required time or performance. Generally, we perform the following types of analysis −
Worst-case − The maximum number of steps taken on any instance of size a.
Best-case − The minimum number of steps taken on any instance of size a.
Average case − An average number of steps taken on any instance of size a.
Amortized − A sequence of operations applied to the input of size a averaged over time.
Different types of algorithms
A brute force algorithm essentially attempts all the chances until an acceptable result is found. This is the most fundamental and least complex type of algorithm. Such types of algorithms are moreover used to locate the ideal or best solution as it checks all the potential solutions. Also, it is used for finding an agreeable solution (not the best), basically stopping when an answer to the issue is found. It is a clear way to deal with an issue that is the first approach that strikes our mind after observing the issue.
This type of algorithm depends on recursion. In recursion, an issue is comprehended by breaking it into subproblems of a similar kind and calling itself over and over until the issue is unravelled with the assistance of a base condition. It solves the base case legitimately and afterwards recurs with a more straightforward or simpler input every time. It is used to take care of the issues which can be broken into less complex or more modest issues of the same sort.
1)Dynamic Programming Algorithm
This type of algorithm is also called the memoization technique. This is because, in this, the thought is to store the recently determined outcome to try not to figure it over and over. In Dynamic Programming, partition the unpredictable issue into more modest covering subproblems and putting away the outcome for sometime later. In simple language, we can say that it recollects the previous outcome and uses it to discover new outcomes.
2)Divide and Conquer Algorithm
In the Divide and Conquer algorithm, the thought is to tackle the issue in two areas, the first section partitions the issue into subproblems of a similar sort. The second section is to tackle the more modest issue autonomously and afterwards add the joined outcome to create the last response to the issue.
3)Greedy Algorithm
Now coming towards another type that is a greedy algorithm, so in this, the solution is created portion by portion. The finding to select the following role is accomplished on the purpose that it provides the sudden help and it never deems the options that had assumed lately.
4)Backtracking Algorithm
In this type of algorithm, the issue is worked out steadily, for example, it is an algorithmic-procedure for taking care of issues recursively by attempting to construct an answer steadily, each piece, in turn, eliminating those solutions that neglect to fulfil the conditions of the situation at any point of time.
5)Randomized Algorithm
In this type of algorithm, a random number is taken for deciding at least once during the computations.