Algorithm and Flow Chart
Algorithm and Flow Chart
1.1 Introduction
1.3 Algorithm
1.1 INTRODUCTION
Intelligence is one of the key characteristics which differentiate a human being from other living creatures
on the earth. Basic intelligence covers day to day problem solving and making strategies to handle
different situations which keep arising in day to day life.
During the process of solving any problem, one tries to find the necessary steps to be taken in a sequence.
In this Unit you will develop your understanding about problem solving and approaches.
Can you think of a day in your life which goes without problem solving? Answer to this question is of
course, No. In our life we are bound to solve problems. In our day to day activity such as purchasing
something from a general store and making payments, depositing fee in school, or withdrawing
money from bank account. All these activities involve some kind of problem solving. It can be said that
whatever activity a human being or machine do for achieving a specified objective comes under problem
solving.
Example1: If you are watching a news channel on your TV and you want to change it to a sports channel,
you need to do something i.e. move to that channel by pressing that channel number on your remote.
This is a kind of problem solving
Now, broadly we can say that problem is a kind of barrier to achieve something and problem solving is
a process to get that barrier removed by performing some sequence of activities Here it is necessary to
mention that all the problems in the world ca’not be solved.
There are some problems which have no solution and these problems are called Open Problems.
1.3 ALGORITHM
Algorithm can be defined as: “A sequence of activities to be processed for getting desired output from a
given input.”
Webopedia defines an algorithm as: “A formula or set of steps for solving a particular problem. To be an
algorithm, a set of rules must be unambiguous and have a clear stopping point”. There may be more than
one way to solve a problem, so there may be more than one algorithm for a problem.
Now, if we take definition of algorithm as: “A sequence of activities to be processed for getting desired
output from a given input.” Then we can say that:
2. One will get output only if algorithm stops after finite time.
Before writing an algorithm for a problem, one should find out what is/are the inputs to the algorithm
and what is/are expected output after running the algorithm. Now let us take some exercises to develop
an algorithm for some simple problems: While writing algorithms we will use following symbol for
different operations:
of X*3
Expected output:
Algorithm:
Problem2: Write an algorithm to read two numbers and find their sum.
First num1.
Second num2.
Expected output:
Algorithm:
Step1: Start
Step6: End
Temperature in Fahrenheit
Expected output:
Temperature in Celsius
Algorithm:
Step1: Start
Step 3: C 5/9*(F32)
Step5: End
1.3.2 Properties of algorithm
Donald Ervin Knuth has given a list of five properties for an algorithm, these properties are:
1) Finiteness:
An algorithm must always terminate after a finite number of steps. It means after every step one reach
closer to solution of the problem and after a finite number of steps algorithm reaches to an end point.
2) Definiteness:
Each step of an algorithm must be precisely defined. It is done by well thought actions to be performed
at each step of the algorithm. Also the actions are defined unambiguously for each activity in the
Algorithm.
3) Input:
Any operation you perform need some beginning value/quantities associated with different activities in
the operation. So the value/quantities are given to the algorithm before it begins.
4) Output:
One always expects output/result (expected value/quantities) in terms of output from an algorithm.
The result may be obtained at different stages of the algorithm. If some result is from the intermediate
stage of the operation then it is known as intermediate result and result obtained at the end of
algorithm is known as end result. The output is expected value/quantities always have a specified
relation to the inputs
1.4 FLOWCHART
The flowchart is a diagram which visually presents the flow of data through processing systems. This
means by seeing a flow chart one can know the operations performed and the sequence of these
operations in a system. Algorithms are nothing but sequence of steps for solving problems. So a flow chart
can be used for representing an algorithm. A flowchart, will describe the operations (and in what
sequence) are required to solve a given problem. You can see a flow chart as a blueprint of a design you
have made for solving a problem.
For example
Suppose you are going for a picnic with your friends then you plan for the activities you will do there. If
you have a plan of activities then you know clearly when you will do what activity. Similarly when you
have a problem to solve using computer or in other word you need to write a computer program for a
problem then it will be good to draw a flowchart prior to writing a computer program. Flowchart is drawn
according to defined rules.
There are 6 basic symbols commonly used in flowcharting of assembly language Programs: Terminal,
Process, input /output, Decision, Connector and Predefined Process. This is not a complete list of all the
possible flowcharting symbols, it is the ones used most often in the structure of Assembly language
programming
1.4.4 Some examples of Flowcharts
Now, we will discuss some examples on flowcharting. These examples will help in proper understanding
of flowcharting technique. This will help you in program development process in next unit of this block.
As we discussed flow chart is used for representing algorithm in pictorial form. This pictorial
representation of a solution/system is having many advantagrs.These advantages are as follows:
1) Communication:
A Flowchart can be used as a better way of communication of the logic of a system and steps involve in
the solution, to all concerned particularly to the client of system.
2) Effective analysis:
3) Documentation of Program/System:
Program flowcharts are a vital part of a good program documentation. Program document is used for
various purposes like knowing the components in the program, complexity of the program etc.
Once a program is developed and becomes operational it needs time to time maintenance. With help of
flowchart maintenance become easier.
Any design of solution of a problem is finally converted into computer program. Writing code referring
the flowchart of the solution become easy.