Table of Contents
Algorithm and flowchart
In This article “What is algorithm and flowchart” We will discuss about algorithm and flowcharts, algorithm/flowchart design & algorithm and flowchart examples . Through this article we will try to understand difference between algorithm and flowcharts as well.
ALGORITHMS
Solving a problem on computer is not much different from solving it manually. In human mind, a sequence of actions are performed in the process of solving a problem. To solve a problem on computer also, the problem should be divided in the sequence of operations. As many operations as required may be taken. Writing these operations in the form of instructions in sentential form of natural languages (such as English) is called algorithm. An algorithm should possess the following properties:
- (i) Application of the algorithm to a particular set of inputs or problem description results in a sequence of actions.
- (ii) There is a unique starting point.
- (iii) Termination of the execution of algorithm may not be at unique point.
- (iv) Each action has a unique successor. (v) The number of steps in an algorithm is fixed.
- (vi) A step of the algorithm may be executed a number of times including zero.
Algorithms are written mostly in the form of pseudocodes. A pseudocode is a sequence of instructions which is not a real program code or a complete English sentence. It is somewhere in between. It is an effective way to describe an action to be performed.
Algorithms are good for programmers as they can express the design of programs conveniently. The description of an instruction in an algorithms matches with both English as well as programming language. The algorithms are compact and can be described easily in few pages of paper. Therefore, they are preferred our the flowcharting (section 2.2). Algorithms fail to express the control flow in visual form. There are no standard format of algorithms, that use any syntax or semantic scheme.
FLOWCHARTS
The flowcharts are pictorial representation of describing a sequence of operations on data. Flowcharts are convenient alternative to the algorithm where a narrative description of program is given. However these flowcharts have demerit of occupying a larger space on paper during the program development process. Various characteristics of flowcharts are similar to the algorithm.
Flowcharts make the control flow logic clear and understandable through the pictures. They are also helpful in effective program coding, effective analysis, debugging, manual testing, modeling and communicating the idea of programming. The programmers initially depends upon the flowchart in order to be comfortable with program writing.
Flowcharts, on other hand, are complex to handle for the larger problems. The modification or any kind of revision is tedious (or sometimes difficult) using to handling of the pictures along with the text. The programmers normally do not update the flowcharts as they do update the programs frequently.
ALGORITHM and FLOWCHART DESIGN
Algorithms and flowcharts both consist of instructions or steps organized in a sequence form so that it becomes clear how control flow occurs i.e. what step is executed at what place and time. The arrangement of sequencing the instructions is done through the control structures. In any programing system or environment there are three type of control structures:
- Sequence (or straight line arrangement)
- Conditional (or decision, selection or branching)
- Loop (repetition, iteration or recursion)
Sequence control structure:
This control structure consists of a sequence of instruction written one after other in a straight line format as shown in Figure below in both manners-flowchart and algorithm.
Conditional control structure:
In a conditional control flow, a step of making a decision is encountered to make a choice between two alternate sequences. Figure below shows the situation of choice in the term of yes or no.
Loop control structure :
In a loop control, a set of instruction are repeated, which may be subject to a condition or without condition. Figure below shows a loop control with a condition. In case of without condition, the loop shall execute infinitely which is an undesired situation when we want to stop the flowchart execution.
Algorithm and Flowchart examples
In this section, we develop algorithms and/or flowcharts for a number of example problems.
Example- Develop an algorithm for adding two numbers.
Algorithm
- 1. Computer obtains the first number say A
- 2. Computer obtains the second number say B
- 3. Computer adds A and B giving result, say C
- 4. Computer displays the value of C, which is the result
- 5. Computer stops execution
End-of-Algorithm
The step by step development of the algorithm can be described as follows: To start with, since the computer is required to add two numbers, it should obtain these numbers first. Step 1 and step 2 are written to effect this. As soon as two numbers are received by the computer, it can add them storing the result. Since the result is available, the computer displays the same in step 4. Since the problem is solved, the computer can stop as instructed in step 5. The same algorithm can be written in a short form as follows:
- 1. Obtain the value of A
- 2. Obtain the value of B
- 3, C = A+B
- 4. Display C
- 5. Stop
End-of-Algorithm.
Note that we have tried to divide the problem in a number of steps. For most of the time during development of algorithm, we may go on thinking that if we solve the problem manually, what will be the sequence of operations performed by our mind? We may write down the operations in sequence.
Let us now draw a flowchart for the same problem. Figure below shows the Flowchart for the above example
Note the use of [box] to indicate start and stop operation, a pentagon formed by cutting the left upper corner from a rectangle for input and output operations and a pure rectangle for processing performed by the computer.
Hope you liked this article on “What is algorithm and flowchart”. You are invited for any kind of suggestion or feedback in the comment box. You can also mail us your suggestions or feedback directly at theinstrumentguru@gmail.com. To read more such articles related to Technology, Electronics and Instrumentation. You can also download our Android App. Click here to download the mobile app.
Read Also
- Number System | Types, Conversion rules & Examples
- P&ID symbols | ISA Symbols and Loop Diagrams
- Difference between analog and digital signal
- What is LVDT ? | Types & Applications
- Digital Integrated Circuit | What is an ICs?
- Resistor transistor logic (RTL)
- Diode Transistor Logic (DTL)
- Direct coupled Transistor Logic (DCTL)
- What is computer programming