Algorithm and Flowchart in Programming

Algorithm

The word “algorithm” relates to the name of the mathematician Al-khowarizmi, which means a procedure or a technique. An algorithm is often used by software engineers to plan and solve problems.

Definition 1: An algorithm is a method or set of rules to be followed in calculations or other problem-solving operations.

Definition 2: An algorithm is a set of rules/instructions that specify how a work is to be conducted step-by-step in order to get the desired results.

Definition 3: An algorithm is a series of defined actions that generates a result and terminates at a finite time that solves a specific problem.

Algorithm has the following characteristics

  • Input: An algorithm may or may not require input
  • Output: Each algorithm is expected to produce at least one result
  • Definiteness: Each instruction must be clear and unambiguous.
  • Finiteness: If the instructions of an algorithm are executed, the algorithm should terminate after finite number of steps

Advantages of algorithm

  • An algorithm uses a definite procedure.
  • It is a step-wise representation of a solution to a given problem, which makes it easy to understand.
  • It is not dependent on any programming language, so it is easy to understand for anyone even without programming knowledge.
  • Every step in an algorithm has its own logical sequence so it is easy to debug

Example

  • START
  • Read 3 numbers a, b, c
  • Compute Sum = a+b+c
  • Compute Average = sum/3
  • Print average value
  • STOP

Flowchart

Flowchart is often considered as a blueprint of a design used for solving a specific problem.

A flowchart is a graphical representation of an algorithm. Programmers often use it as a program-planning tool to solve a problem. It makes use of symbols which are connected among them to indicate the flow of information and processing.

The process of drawing a flowchart for an algorithm is known as “flowcharting”.

Standard flow chart symbols

Flowchart examples

1. Add two numbers entered by the user.

2. Find the largest among three different numbers entered by the user.

3. Find all the roots of a quadratic equation ax2+bx+c=0

4. Find the Fibonacci series till term≤1000.

Algorithm vs Flowchart

#AlgorithmFlowchart
1.Algorithm is step by step procedure to solve the problem.Flowchart is a diagram created by different shapes to show the flow of data.
2.Algorithm is complex to understand.Flowchart is easy to understand.
3.In algorithm plain text are used.In flowchart, symbols/shapes are used.
4.Algorithm is easy to debug.Flowchart it is hard to debug.
5.Algorithm is difficult to construct.Flowchart is simple to construct.
6.Algorithm does not follow any rules.Flowchart follows rules to be constructed.
7.Algorithm is the pseudo code for the program.Flowchart is just graphical representation of that logic.
Sources : GeekForGeek.com (for few articles) | Programmiz.com (flowchart images)