In our entire programming life, we use the word most is Algorithm. We can’t even think about a code without the algorithm. In every single code, we use at least one algorithm. Now you may ask what is the algorithm? Why should we use the algorithm in our code? What will happen if we don’t use the algorithm? calm down man calm down!!! Here you will get all of the answers. Just keep reading the article with the patient.
Algorithm: Algorithm is a set of mathematical and logical instructions that solve a certain problem. Does it make any sense? No!!! Ok, don’t worry we are about to remove your all confusions. Suppose you wanna pour a glass of water from a jug. Think about what is to do! At first, you hold the jug and placed it upon the glass such a way the water rolls down in the glass. Here respectively you have done three instructions.
- Holding jug
- Placement
- Pouring water
Just think that if you miss one of the instruction, will you be able to complete the task? No, you can’t. Even without maintaining the sequence, you won’t be able to complete the task. Cause you are not working logically. In the same way, we can’t code to solve a problem without logical instruction. And logical instruction means an algorithm. Sometimes we need to do some mathematical instruction. So we can say Algorithm is a set of mathematical and logical instructions. There are four distinct areas of study which help to produce a perfect algorithm to solve a particular problem.
- Devise Algorithm: Devise Algorithm is an art. It can’t do everyone and it may never be automated. The first step to solve a problem is to devise and design an algorithm that solves the problem optimally. There are various design techniques that have proven to be useful for yielding good algorithms. For example Recursion and backtracking.
- Validate Algorithm: After devising an algorithm next part is to validate the algorithm. Validate Algorithm refers that it can compute the correct answers for all possible legal inputs. The purpose of the validation is to assure that the algorithm working properly and correctly if it is written in programming languages. After validation, the next phase is to check each statement are using correctly in the program. Cause extra unused statement is not good to design a perfect algorithm.
- Analyze Algorithm: After executing an algorithm, it uses the computer’s CPU to perform and its memory to hold the program code and data. Analyze algorithm or performance analysis refers to determining how much computing power and memory spaces are requires of an algorithm. This analysis result allows us to make a sense about creating the best and efficient algorithm for a particular problem.
- Test a Program: Testing a program refers to two-phase: one is debugging and another one is profiling.
Debugging refers to correct the faultiness that occurs during the executions of a program for a sample data. If we don’t get desire result after executing the program then we need to fix it this is called Debugging.
Profiling refers to the performance measurement of a program. Measuring the performance time to get the desired result for a sample input of a program is called profiling.
There are some techniques to design a perfect algorithm and that has proven to be useful for yielding good algorithms:
- Linear method
- Divide and conquer method
- Backtracking method
- Greedy method
- Dynamic programming method
- Branch and bound method
Next articles we will discuss these techniques more deeply.
Hopefully, you have got your all questions answer and a better knowledge about Algorithm. If you have any question then feel free to ask. Do your precious comment to improve us and stay Happy.
Leave a comment