Algorithm is a finite sequence of instructions, each of which have clear meaning and can be executed with a finite amount of effort in finite time. It is the instruction for operation to the computer of any input values to produce output.
An algorithm is any well defined computational procedure that takes some value or set of values as input and produces some value or set of values as output. Thus the algorithm is a sequence of steps that transform the input into output.
An algorithm is a set of instruction to be performed
to solve the desired problem.
We can view an algorithm as a tool for solving well-defined computational problem. In algorithm, we define the statements for computer to solve the specific problem in general terms with desired input and output relationship.
Step-by-step procedure to solve the problem
Well done now we are aware about what actually algorithm is? But why algorithm is needed? As we know computer have limited space and speed. To make any program faster we need algorithm. Best algorithm is efficient in terms of space and time. One method for analyzing time complexity of an algorithm is Big O notation, here we calculate the efficiency of algorithm in time domain.
Good algorithm should be optimized in terms of time and space
What if computer have infinite speed and space for execution? In this case we want to implement algorithm within the bounds of good software engineering practice. Definitely we use which method is easiest to implement. Here also comes algorithm. Hence the algorithm has huge importance in software engineering and software developing field.
There are different types of Algorithms:
1. Brute force algorithm
It is basic and simplest. It is the first approach that comes to our mind on seeing the problem
2. Recursive algorithm
It is based on recursion. Problem is solved by breaking it into sub-problem of the same type and calling own self again and again until the problem is solved with the help of base condition.
3. Divide and conquer algorithm
It is top-down technique for designing algorithm. It includes three phases:
- Divide: Problem is divided into smaller sub problems.
- Conquer: Solve sub-problems by calling recursively until solved.
- Combine: Combine the sub-problems to get the final solution of the whole problem.
4. Dynamic programming algorithm
It is also known as memorization technique because in this algorithm, the idea is to store the previously calculated result to avoid calculating it again and again. Divide the complex problem into smaller overlapping sub-problems and storing the result for future use.
5. Greedy algorithm
The decision to choose the next part is done on the basis, that it gives the immediate benefit. It never consider the choice that had taken previously.
6. Back tracking algorithm
Problem is solved in an incremental way.
7. Deterministic and non-deterministic algorithm
Deterministic algorithm is an algorithm in which, for a particular input computer will give always same output. Can be solve the problem in polynomial time and can determine the next step.
In non-deterministic algorithm, for a particular input, computer will give different output on different execution. It can't determine the next step of execution due to more than one path the algorithm can take.
8. Series and parallel algorithm
It depends on the architecture of computer.
Sequential algorithm is an algorithm in which some consecutive steps of instructions are executed in a chronological order to solve the problem.
In parallel algorithm, the problem is divided into sub problems and are executed in parallel to get individual outputs. Later on, these individual outputs are combined together to get final desired output.
9. Heuristic and approximate algorithm
Heuristic algorithm is used to design the solution to the problem as quickly as possible. It may not produce the best solution but it will give a near optimal solution in short time. It decrease the time complexity of problems and used in AI problems.
Approximate algorithm does not guarantee the best solution. The goal of approximation algorithm is to come close as much as possible to the optimal solution in polynomial time. It guarantees to seek out high accuracy and top quality solution.
Comments
Post a Comment