Explaining Algorithm and Flowchart
Explaining Algorithm and Flowchart
Algorithm :
The name Algorithm is given after the name of Abu Ja’far Muhammad ibn Musa Al-Khwarizing, Ninth Century, is defined as follows:
- An algorithm is a set of rules for carrying out calculation either by hand or on a machine.
- An algorithm is a sequence of computational steps that transform the input into the output.
- A finite set of instruction that specifies a sequence of operations to be carried out in order to solve a specific problem or class of problems is called an algorithm.
- It is an abstraction of a program to be executed on a physical machine (model of computation).
The important tools used in the preparation of an algorithm are flowcharts and pseudocodes among others.
Characteristics of an Algorithm
- Finiteness: This means that an algorithm must terminate after a finite number of steps.
- Definiteness: This states that each and every step of an algorithm must be rigorously and unambiguously defined.
- Input: The algorithm should take zero or more inputs.
- Output: The algorithm should produce one or more outputs.
- Effectiveness: This means that a human should be able to calculate the values involved in the procedure of algorithm using pencil and paper.
Advantages & Disadvantages of Algorithm
- An algorithm is a definite list of well-defined instructions for completing a task.
- An Algorithm provides initial state
- Eventually terminating in an end-state
- Easier to understand.
- Provides step by step procedure to solve the problem
Disadvantages of Algorithm:
- Time consuming
- Space consuming
Design an algorithm to calculate the sum of ‘n’ numbers, assuming that ‘n’ is greater than or equal to zero.
Problem Definition:
Given a set of n numbers, design an algorithm that adds these numbers and produces the resultant sum. Assume ‘n’ is greater than or equal to zero.
Step 1: Prompt and read in the numbers of numbers (n) to be. summed.
Step 2: Initialize sum to zero.
Step 3: While less than n have been summed up, repeatedly do,
(a) Read next number.
(b) Compute current sum by adding the number read to the most recent sum.
Step 4: Write out the sum of n numbers.
Step 5: Stop.
Flowcharts :
A program flowchart is a pictorial representation of logic required to accomplish a task. It includes all necessary steps of a program. It is called flow chart because it charts the flow of a program. It is a symbolic representation of each input, output and processing step. Besides, being a good method of writing down the algorithm, it is also a part of program documentation and helps in understanding, debugging and maintaining programs.
In a flowcharting techniques, operations are represented by drawing appropriate symbols for the actions. Traditional program flowcharting involves the use of simple geometric symbols to represent the beginning or end of a program, a process, a decision or an input-output process. These flowcharts symbols are connected by arrows to illustrate the sequence of operations.
It is graphic presentation using symbols to show the step-by-step sequence of operations, activities, or procedures. It is used in computer system analysis, activity analysis, and in general program sequence representations.
Advantages & Disadvantages of Flowcharts
Advantages of Flowcharts:
- Provides a Visual Representation which is often easier to understand.
- Flowcharts can be easy to code from, provided only recognizable, standardized flow sequences are drawn.
- Encourages us to work linearly “depth-first”;
Disadvantages of Flowchart:
- Time consuming
- Space consuming
- Requires template or special software
- Permits development of logic sequences
- Using valid structured code
The role of algorithm and flowcharts in the problem solving:
As a computer can not think on its own, the programmer has to provide a method to solve a problem. After defining the problem, the programmer writes the procedure how to solve the problem. The procedure must be written in the form of a series of steps in a logical sequence. A precise statement of the procedure required for solving a problem is called an algorithm. Having obtained an algorithm for solving a problem, the algorithm is expressed in a pictorial form called a flowchart. A flow chart is essentially a diagram or picture which defines the procedure how to solve the problem. A flow chart shows the order of operations. It also shows the relationship between the sections of the program. Flow charts are independent of a particular computer or computer language.
The figure shows the standard symbols which are usually used in drawing flowcharts.
Similarly, in Algorithm, we use some steps to write it.
Example :
Flowchart and Algorithm to add two numbers:
Difference between Algorithm and Flowchart with Example
Algorithm :
An algorithm is a sequence of fundamental instructions. If the algorithm is correct then solution provided by the computer will be correct. If the algorithm is not correct, this solution provided by the humans may be still correct but not provided by the computers.
Flowcharts :
The flowchart is an old design tool which is still in use. It provides a better understanding of existing and prepared methods and procedures and systems. A flowchart may be a graphical representation of the definition, analysis or solution of a problem using symbols to represent operations, data flow equipment and the like. The flowcharts can be divided into two categories:
a. Program Flowcharts: Program flowcharts describe the process taking place within an individual program in the system and the sequence in which they must be executed.
b. System Flowcharts: System flowcharts detail the flow of data throughout an entire information system.
Algorithm |
Flowchart |
1. It is a step by step solution of the problem. | 1. It also steps by step solution to the problem but in the pictorial form. |
2. In the algorithm, we use simple language by English. | 2. In the flowchart, we use a special symbol like input, output box. |
3. The algorithm provides either to the computer or to a human being an unambiguous instruction to solve a problem. | 3. It provides a better understanding of existing and prepared methods and procedures and systems. |
4. It is not easy to understand. | 4. It is easy to understand. |
Example:
How to Make two Cup of Tea
Let us use Algorithm:
- Take three variable A, B, Sum.
- The input value of A, B.
- Add the value of A & B and store in Sum.
- Print Sum
Now, we will take the help of flowchart: