Understanding Algorithm: Complexity and Performance
Algorithm and Flowchart: Differences Explained
What is an Algorithm?
Algorithms and flowcharts are used for the representation of a program in a different manner, especially in computer programming. An algorithm is a step-by-step procedure, which has to be followed when an input is given to obtain the desired output or result. It is generally represented in form of steps during the execution. Algorithms give a vague idea of logic to be implemented to get the desired output from the given input.
Example:
Let's take an example of a simple program for better understanding of algorithms in computer programming. Below is the algorithm to be followed to print the sum, average of given 5 numbers.
Steps to be followed:
- Take 5 numbers as input from the user. Let them be A1, A2, A3, A4, A5.
- Now, sum the values of (A1+A2+A3+A4+A5) and store them in a variable called sum.
- Average of five numbers is sum/5 which is stored in variable avg.
- Return the values stored in sum, avg as output.
What is a Flowchart?
On the other hand, a flowchart is a graphical representation of the steps to be followed of a program takes to obtain the desired output. Flowchart uses many geometric shapes to indicate different steps. Each geometric shape represent one different step. For example, a diamond shape indicates an execution of if/else statement. An oval/ round rectangle represents the start and end of the program. A rectangle shape indicates the block of code which consists of numbers manipulation or printing statements, etc. The below given image represents the overall idea of the flowchart on the computer programming.
Algorithm Vs Flowchart
Conclusion
This article mainly explained about the key differences between algorithm and flowchart. The algorithm is like a set of rules to be followed to obtain the desired output from the given input, whereas a flowchart is a graphical representation and gives more clarity for the user to understand the computer program in a better manner. But comparatively, a flowchart for a huge program becomes clumsy therefore an algorithm is preferred for huge programs.