ALGORITHM
The word Algorithm means method, technique or procedure. We all know that a computer processes the input according to the instructions given to it. Let us see how instructions are given to the computer.
Suppose we have to find the average of two numbers. The steps required are:
Step 1 Take two numbers
Step 2 Add them to get a sum
Step 3 Divide the sum by 2, to get the average
When we write the tasks involved in doing a job or task in a stepwise order, we call it an Algorithm.
An Algorithm can be defined as a step-by-step procedure for solving a given problem.
Let's take an example of an algorithm:
Write an algorithm - 'To call a friend'.
Step 1 Go to the telephone.
Step 2 Pick up the receiver.
Step 3 Check the dial tone. If dial tone is not available wait for the dial tone.
Step 4 If dial tone is present, then dial the telephone number of your friend.
Step 5 If bell is not ringing then try after some time.
Step 6 If bell is ringing, wait for somebody to pick up the telephone receiver.
Step 7 Call your friend on the telephone.
Step 8 Talk to him/her.
Step 9 After talking, disconnect the (line of) telephone.
Step 10 Put the receiver back.
Characteristics of an algorithm
- Simple but produces meaningful and correct solutions.
- Easily understandable and quickly implementable.
- Can be modified easily.
- Economically uses the time, storage and computer peripherals.
- Not dependent on a particular computer language.
Let's take another example of an algorithm:
Write an algorithm - 'To make tea. Either milk tea or lemon tea'.
Step 1 Take a pan.
Step 2 Put some water in the pan.
Step 3 Light the gas stove.
Step 4 Put the pan on the gas stove.
Step 5 Put tea-leaves in water and boil it.
Step 6 Decide the type of tea either milk tea or lemon tea.
Step 7 If it is milk tea then add milk to it else squeeze lemon in it.
Step 8 Decide sugar to be added or not.
Step 9 If yes, then add the sugar otherwise do not.
Step 10 Take off the pan from the gas stove.
Step 11 Filter the tea to pour it into the cups.
Step 12 Serve the tea to the respective person.
FLOWCHART
Guidelines for preparing proper flowcharts
- The flowchart should be neat and easy to follow so that it will be clearly understood.
- A logical start and end must be given to the flowchart.
- The flowchart should include necessary steps in logical order.
- The only one flow line should come out from a process symbol.
- The decision making symbol should have only one incoming flow line. However, it may have two or three out-going flowlines.
- The terminal symbols, that is, Start and Stop / End symbols should have only one flow line.
- The symbol should contain the information (process, data or text) clearly to carry out the required action.
Benefits of Flowcharts
A flowchart is a step next to algorithm. The sequential steps in the algorithm are pictorially represented by the flowchart. This helps to clarify the actions to be taken. It also allows to improve the currently working things. The misplaced steps or unnecessarily included steps are clearly come into picture with the help of flowchart. The flowchart is a problem solving tool. The benefits of using it are discussed below.
- Logic understanding
Since the flow chart pictorially represents the actions to be performed, the logic used for solving the problem can be understood easily. The symbols used to perform various functions show the actions and their flow. Thus the actions with their sequence of execution can be cleared easily even to a non-expert or less experienced person with the help of flowchart. The fundamental control structures in computer programming can be visualized using flowcharts.
- Communication
The participants are communicated in process of flowchart development. Since the logic is pictorially represented, a common understanding about the process is established between them. It is a better way of communicating the logic of a system to all concerned. The flowchart makes the communication easier to all the involved people as compared to actual program code because all of them may not be aware of all the programming techniques and languages.
- Effective analysis
Actually, it is the duty of the programmer to analyze the problem. However, it can be handed over to other persons who may or may not be aware of the programming techniques. This becomes possible because of flowchart which gives broad idea about the logic. The testing and analysis of the logic is performed in an unbiased manner by these people. Thus the analysis of the problem becomes effective and easier because of flowchart.
- Useful in coding
When the flowchart becomes ready, the start and end are fixed along with all the necessary sequential steps. This flowchart acts as a guide to the programmer in planning the coding process effectively. Thus the flowcharts allow the programmer to develop error free programs in high-level languages at a faster rate.
- Proper testing and debugging
The errors in the program can be detected using flowchart. The logic used for solving the problem is exactly known to the developer. The developer can test a process by applying various data. This allows the testing of program in every contingency.
- Appropriate documentation
Most of the times the programs are developed for beginners. They can understand what the program actually does and how to use the program with the help of documentation. Flowcharts serve as good documentation tool for beginners.
Limitations of Flowcharts
The basic concept of the program can be understood by the flowchart. However, it cannot be used for programming. The programming should be done using language. Some of the limitations of the flowchart are discussed below.
- Complex
When a program is very large, the flowchart drawn for it needs many pages. It needs large efforts. The understanding of logic using such flowchart becomes difficult.
- Costly
If the problem-solving logic is straightforward and not very lengthy, flowcharts can be drawn easily and cost factor remains in proportion. However, if the application or the system is very large, the time taken for drawing flowcharts is very large and also the cost of factor goes out of proportion. That is, flowchart drawing process becomes costly.
- Difficult to modify
If any change in the symbol used in the flowchart or any modification to a flowchart is to be done, it is necessary to redraw the flowchart. This job becomes very tedious for a large or lengthy or complex flowcharts. Such flowcharts contain a large number of symbols, flow lines with proper spacing on a number of pages. So changing flowchart is not a simple task.
- No update
The user can easily understand the logic of the program using the flowchart. As per the requirements, the programs are updated regularly. However, the corresponding changes in the flowchart are not done, especially when the programs and hence the flowcharts are large or lengthy or complex. Because of this inconsistency in the flowchart, the user may not understand the logic used in the program. That is, the flowchart does not serve its basic purpose.
Test your knowledge - Algorithm and Flowchart Quiz