Wed Oct 06 2021 (2 months ago)
Engineer by mistake!
I am a software engineer by passion
The algorithm is a finite set of well-defined sequential instructions to perform any task. In computer science and mathematics, algorithms are used to solve a class of specific problems or perform any sort of computation.
A simple real-life algorithm could be making a cup of tea. You will not believe it but, making a tea is an algorithm where you have to follow some set of instructions in a sequential manner to get the final tea.
Put the tea bag in a cup
Fill the kettle with water
Boil the water in the kettle
Pour some of the boiled water into the cup
Add milk to the cup
Add sugar to the cup
Stir the tea
Drink the tea
You can see that we have to follow the steps to get the fine tea. So, these steps can be said as the instruction and they need to follow in a sequential manner. Because you can not reach step 8 before step .
Input - The algorithm must have input values from some specified set.
Output - The algorithm must provide output.
Finiteness - The algorithm must terminate after a finite number of steps.
Definiteness - All steps of the algorithm should be well defined.
Effectiveness - It must possible to perform each step of the algorithm correctly in a finite amount of time.
Read the input
Process the input
Produce the output
An algorithm is a set of well defined sequential instructions to perform any task, whereas programs are the code written in any programming language to be executed by the computer.
An algorithm can be represented in three ways.
A set of instructions written in plain English
In general, for any problem, there could be many ways to solve them. The same thing applies to algorithms too, we have few design techniques as follows.
Branch and bound algorithms
Brute force algorithms
Divide and conquer algorithms
Dynamic programming algorithms
© 2021 dsabyte. All rights reserved