Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
63 views

Algorithm Defination Design Implementation

Uploaded by

mdmasumice
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
0% found this document useful (0 votes)
63 views

Algorithm Defination Design Implementation

Uploaded by

mdmasumice
Copyright
© © All Rights Reserved
Available Formats
Download as PDF or read online on Scribd
You are on page 1/ 7
WHAT IS AN ALGORITHM? It is a set of instructions of how to carry out a process. An algorithm lists the steps that must be followed to complete the process and to reach the solution Input List Algorithm Output List Examples: + Aknitting pattem + Asset of instructions telling you how to put a kit together (eg. an kitchen unit) + Arecipe in a cook book + An algorithm can be represented diagrammatically in the form of a flow chart, Algorithm constructions: ‘There are three different constructions of algorithms do action | do action 2 0 action a Sequence ira condition Is tu [hie condition is tue, 'b Decision ‘c Repetition Properties of Algorithms: + An algorithm is an exact specification of how to solve a computational problem + An algorithm must specify every step completely, so a computer can implement it without any further “understanding” + An algorithm must work for all possible inputs of the problem. + Algorithms must be: * Correct: For each input produce an appropriate output + Efficient: run as quickly as possible, and use as little memory as possible ~ more about this later + There can be many different algorithms for each computational problem. rithms Phases: A typical programming task can be divided into two phases: 1. Problem solving phase (Designing) + produce an otdered sequence of steps that describe solution of problem + this sequence of steps is called an algorithm 2. Implementation phase + implement the program in some programming language Problem solving phase (Designing) : Steps in Problem Solving + First produce a general algorithm (one can use psetdocode) + Refine the algorithm successively to get step by step detailed algorithm that is, very close to a computer language. + Pseudocode is an artificial and informal language that helps programmers develop algorithms. Pseudocode is very similar to everyday English Pseudocode Example: Example 1; Write an algorithm to determine a student’s final grade and indicate whether it is passing or failing. The final grade is calculated as the average of four marks. Pseudocode: © Input a set of 4 marks © Calculate their average by summing and dividing by 4 «if average is below 50 Print “FAIL” else Print “PASS” ‘The Flowchart: + (Dictionary) A schematic representation of a sequence of operations, as in a manufacturing process or computer program + (Technical) A graphical representation of the sequence of operations in an information system or program. Information system flowcharts show how data flows from source documents through the computer to final distribution to users. Program flowcharts show the sequence of instructions in a single program or subroutine. Different symbols are used to draw each type of flowchart. + shows logie of an algorithm + emphasizes individual steps and their interconnections + e.g. control flow from one action to the next Flowchart Symbols: Nome ‘symbol Puabovan fi] Rectangle -> CO) Hybia Fw ting, ————» Use in Flowenort Denotes the beg ning or end a the program Donotas an input operation Denotes a process to be card out 129, addon, subiracion, dion ete, Denotes a decision for branch) to be made ‘The program should cantiwe along one of ‘wo toutes. (e.g, FTHENELSE) Donoios an output operation Denotes the dection of age Yow inthe program + A flowchart consists of a sequence of instructions linked together by arrows to show the order in which the instructions must be carried out. + Itprovides detailed steps. + Each instruction is put into a box. The boxes are different shapes depending upon what the instruction is. Example 1: MAKING A CUP OF TEA! Pseudocode: 1, Take tea bag out of cup Boil the water Put tea bag in cup ‘Add milk? Pour boiling water in cup Fill kettle Stir Ready ee Nae ee DY ‘Add sugar ? 10, Fetch cup Algorithm: 1. Fill kettle Boil the water Fetch cup Put tea bag in cup Pour boiling water in cup Take tea bag out of cup ‘Add sugar ? Stir Add milk? ee Nae ee 10. Stir 11. Ready Example 2: Gar) Grade students to identify pass & fail. LEEW Algorithm: Step I: Input M1,M2,M3,M4 Step2; GRADE « (M14M24M34Mayi4 x cite x Step3: if (GRADE

You might also like