The document discusses algorithms and flowcharts. It defines an algorithm as a sequence of steps to solve a problem using a computer. A flowchart is a graphical representation of an algorithm that shows the steps. The document gives examples of flowcharts symbols like terminator, process, decision, connector, and data. It also provides examples of algorithms for problems like finding the sum, average, and product of numbers, and determining the largest of two numbers. The key benefits of algorithms and flowcharts are efficiency, abstraction, and reusability in problem solving.
The document discusses algorithms and flowcharts. It defines an algorithm as a sequence of steps to solve a problem using a computer. A flowchart is a graphical representation of an algorithm that shows the steps. The document gives examples of flowcharts symbols like terminator, process, decision, connector, and data. It also provides examples of algorithms for problems like finding the sum, average, and product of numbers, and determining the largest of two numbers. The key benefits of algorithms and flowcharts are efficiency, abstraction, and reusability in problem solving.
Technical Engineering college - Basra A computer is a useful tool for solving a great variety of problems. To make a computer do anything (i.e. solve a problem), you have to write a computer program. In a computer program you tell a computer, step by step, exactly what you want it to do. The computer then executes the program, following each step mechanically, to accomplish the end goal. The sequence of steps to be performed in order to solve a problem by the computer is known as an algorithm.
Flowchart is a graphical or symbolic representation of an
algorithm. It is the diagrammatic representation of the step-by- step solution to a given problem.
Program Design consists of the steps a programmer should do
before they start coding the program in a specific language. Proper program design helps other programmers to maintain the program in the future. Let us follow an example to help us understand the concept of algorithm in a better way. Let’s say that you have a friend arriving at the railway station, and your friend needs to get from the railway station to your house. Here are three different ways (algorithms) that you might give your friend for getting to your home. All these three algorithms accomplish the same goal, but each algorithm does it in a different way. Each algorithm also has a different cost and a different travel time. Taking a taxi/auto-rickshaw, for example, is the fastest way, but also the most expensive. Taking the bus is definitely less expensive, but a whole lot slower. You choose the algorithm based on the circumstances. In computer programming, there are often many different algorithms to accomplish any given task. Each algorithm has advantages and disadvantages in different situations. Sorting is one place where a lot of research has been done, because computers spend a lot of time sorting lists. Three reasons for using algorithms are efficiency, abstraction and reusability. - Efficiency: Certain types of problems, like sorting, occur often in computing. Efficient algorithms must be used to solve such problems considering the time and cost factor involved in each algorithm. - Abstraction: Algorithms provide a level of abstraction in solving problems because many seemingly complicated problems can be distilled into simpler ones for which wellknown algorithms exist. - Reusability: Algorithms are often reusable in many different situations. The benefits of flowcharts are as follows: Communication: Flowcharts are better way of communicating the logic of a system to all concerned. Effective analysis: With the help of flowchart, problem can be analysed in more effective way. Proper documentation: Program flowcharts serve as a good program documentation, which is needed for various purposes. Efficient Coding: The flowcharts act as a guide or blueprint during the systems analysis and program development phase. Proper Debugging: The flowchart helps in debugging process. Efficient Program Maintenance: The maintenance of operating program becomes easy with the help of flowchart. It helps the programmer to put efforts more efficiently on that part. Although a flowchart is a very useful tool, there are a few limitations in using flowcharts which are listed below: Complex logic: Sometimes, the program logic is quite complicated. In that case, flowchart becomes complex and clumsy. Alterations and Modifications: If alterations are required the flowchart may require re-drawing completely. Reproduction: As the flowchart symbols cannot be typed, reproduction of flowchart becomes a problem. Terminator: An oval flow chart shape indicates the start or end of the process, usually containing the word “Start” or “End”.
Process: A rectangular flow chart shape indicates a normal/generic process flow
step. For example, “Add 1 to X”, “M = M*F” or similar. Decision: A diamond flow chart shape indicates a branch in the process flow. This symbol is used when a decision needs to be made, commonly a Yes/No question or True/False test.
Connector: A small, labelled, circular flow chart shape used to
indicate a jump in the process flow. Connectors are generally used in complex or multi-sheet diagrams. Data: A parallelogram that indicates data input or output (I/O) for a process. Examples: Get X from the user, Display X.
Arrow: used to show the flow of control in a process. An arrow coming
from one symbol and ending at another symbol represents that control passes to the symbol the arrow points to. example, consider that we need to find the sum, average and product of 3 numbers given by the user. Write (Display) the Sum, Average and Product : 1 – by draw flow chart 2 - by write an algorithm ( H.W) Consider another problem of finding the largest number between A and B
Algorithm for the above problem is as follows:
Read A, B If A is less than B BIG=B SMALL = A Else BIG=A SMALL = B Write (Display) BIG, SMALL “INTRODUCTION TO C++”, INSTITUTE OF DISTANCE & OPEN LEARNING, Unit One