Chapter 1: Flowchart and Algorithm PDF
Document Details
Uploaded by CrispBagpipes
Tags
Summary
This document introduces the concepts of algorithms and flowcharts. It describes the characteristics of algorithms including input, output, definiteness, and finiteness. It explains the advantages of using algorithms and the general approaches to algorithm design, using the area calculation of a rectangle as an example. A description of flowcharts, their advantages, and importance is included.
Full Transcript
Chapter: 1 Flowchart and Algorithm 1.1 Introduction of algorithm Algorithm: The word “algorithm” relates to the name of the mathematician Al Khwarizmi, which means a procedure or a technique. Software Engineer commonly uses an algorithm for planning and solving the problems. An algorithm is a seque...
Chapter: 1 Flowchart and Algorithm 1.1 Introduction of algorithm Algorithm: The word “algorithm” relates to the name of the mathematician Al Khwarizmi, which means a procedure or a technique. Software Engineer commonly uses an algorithm for planning and solving the problems. An algorithm is a sequence of steps to solve a particular problem or algorithm is an ordered set of unambiguous steps that produces a result and terminates in a finite time Algorithm has the following characteristics. Input: An algorithm may or may not require input Output: Each algorithm is expected to produce at least one result Definiteness: Each instruction must be clear and unambiguous. Finiteness: If the instructions of an algorithm are executed, the algorithm should terminate after finite number of steps Advantages of Algorithm: It is a step-wise representation of a solution to a given problem, which makes it easy to understand. An algorithm uses a definite procedure. It is not dependent on any programming language, so it is easy to understand for anyone even without programming knowledge. Every step in an algorithm has its own logical sequence so it is easy to debug. 1.2 General approaches in Algorithm Design Step 1 Define your algorithms input: Many algorithms take in data to be processed, e.g. to calculate the area of rectangle input may be the rectangle height and rectangle width. Step 2 Define the variables: Algorithm's variables allow you to use it for more than one place. We can define two variables for rectangle height and rectangle width as HEIGHT and WIDTH (or H & W). We should use meaningful variable name e.g. instead of using H & W use HEIGHT and WIDTH as variable name. Step 3 Outline the algorithm's operations: Use input variable for computation purpose, e.g. to find area of rectangle multiply the HEIGHT and WIDTH variable and store the value in new variable (say) AREA. An algorithm's operations can take the form of multiple steps and even branch, depending on the value of the input variables. Step 4 Output the results of your algorithm's operations: In case of area of rectangle output will be the value stored in variable AREA. if the input variables described a rectangle with a HEIGHT of 2 and a WIDTH of 3, the algorithm would output the value of 6. 1.3 Description of Flowchart Flowchart: The first design of flowchart goes back to 1945 which was designed by John Von Neumann. Unlike an algorithm, Flowchart uses different symbols to design a solution to a problem. It is another commonly used programming tool. By looking at a Flowchart one can understand the operations and sequence of operations performed in a system. Flowchart is often considered as a blueprint of a design used for solving a specific problem. Advantages of Flowchart: Flowchart is an excellent way of communicating the logic of a program. Easy and efficient to analyze problem using flowchart. During program development cycle, the flowchart plays the role of a blueprint, which makes program development process easier. After successful development of a program, it needs continuous timely maintenance during the course of its operation. The flowchart makes program or system maintenance easier. It is easy to convert the flowchart into any programming language code. 1.4 Importance of Flowchart Flow charts are an important tool for the improvement of processes. By providing a graphical representation, they help project teams to identify the different elements of a process and understand the interrelationships among the various steps. Improved Communication. Flowchart software empowers entire teams to collaborate as they create, edit, and analyze flowcharts Visual Clarity Effective Analysis and Problem Solving. 1.5 Symbols of Flowchart SYMBOLS OF FLOWCHART: Symbol name Symbol Function Oval Used to represent start and end of flowchart Parallelogram Used for input and output operation Rectangle Used for arithmetic operations and data manipulations Diamond Decision making. Used to represent the operation in which there are two/three alternatives, true and false etc Arrows Flow line Used to indicate the flow of logic by connecting symbols Circle Page Connector 1.6 Structure of flowchart A structured flowchart is one in which all of the processes and decisions must fit into one of a few basic structured elements. One of the processes will be carried out in each path from the binary decision. The WHILE process allows for the representation of a conditional loop structure within a program. 1.7 Limitations of Flowchart Complex logic: Sometimes, the program logic is quite complicated. In that case, flowchart becomes complex and clumsy. This will become a pain for the user, resulting in a waste of time and money trying to correct the problem Alterations and Modifications: If alterations are required the flowchart may require re-drawing completely. This will usually waste valuable time. Reproduction: As the flowchart symbols cannot be typed, reproduction of flowchart becomes a problem. RELATION BETWEEN ALGORITHM AND FLOWCHART: 1. Algorithm & Flowchart to find the sum of two numbers 2. Algorithm & Flowchart to convert temperature from Celsius to Fahrenheit. 3. Algorithm & Flowchart to convert temperature from Fahrenheit to Celsius. 4. Algorithm & Flowchart to find Area and Perimeter of Square. 5. Algorithm & Flowchart to find Simple Interest. 6. Algorithm & Flowchart to find sum of series 1+2+3+…..+N. 7. Algorithm & Flowchart to find Even number between 1 to 50.