210 likes | 319 Views
Chapter 3 : Basic Concepts of Algorithm. Prepared by Madam Zanariah Idrus. Outline. Software Development Life Cycle Algorithm Pseudocode Exercises. Six step procedure Program specification Program design Program code Program test Program documentation Program maintenance.
E N D
Chapter 3 :Basic Concepts of Algorithm Prepared by Madam ZanariahIdrus
Outline • Software Development Life Cycle • Algorithm • Pseudocode • Exercises
Six step procedure • Program specification • Program design • Program code • Program test • Program documentation • Program maintenance Software Development Life Cycle (SDLC) Page 398
Understanding what the problem is? • What is solution should provide? • Inputs to the problem • Any special constraints/condition/ formulas to be used • 75% of total lifetime cost • Error-free operations • Effective program • Two categories • Operations • Changing needs • Plan a solution • Using Algorithm: - Pseudocode - Flowcharts • Written descriptions and procedures about a program • User manual • Transform design to coding • Writing the program or coding SDLC • Debugging • Syntax errors • Logic errors
Pseudo code • a semi formal English – like language with a limited vocabulary, used to design & describe algorithm • Flowchart • a graph consisting of geometrical shapes that are connected by flow lines, used to design & describe algorithm Algorithms
Problem Program Code Algorithm : A sequence of instructions describing how to do a task (or process) From Algorithms to Programs
Both are sets of instructions on how to do a task • Algorithm: • talking to humans, easy to understand • in plain (English) language • Program: • talking to computer (compiler) • can be regarded as a “formal expression” of an algorithm From Algorithms to Programs
Pseudocode Begin Read number1 Read number2 Add number1 & number2 Display sum End • An outline of the logic for your program • A summary of the program Page 403
Flowchart Page 403
SEQUENCE STRUCTURE SELECTION STRUCTURE LOOP STRUCTURE Flowchart: Logic Structures Page 404
Why algorithm is important? • Describe the steps needed to perform a computation • Important for writing efficient code • code that execute faster & which uses less memory
With sequence structure, an action or event is performed in order, one after another. • A sequence can contain any number of events but there is no chance to branch off and skip any of the events. • Once you start a series of events in a sequence, you must continue step‐by‐step until the sequence ends. Sequence Structure
Problem: • Design a software to calculate the sum of two numbers entered by user. Example 1: sequence
(flowchart) (pseudo code) Steps: • Begin • Read no1 • Read no2 • Add no1 & no2 • Display sum • End start Read no1 Read no2 Display Sum answer=no1+no2 end Example: Add 2 numbers