Algorithm Design: by DR Goh Wan Inn
Algorithm Design: by DR Goh Wan Inn
Algorithm Design: by DR Goh Wan Inn
Slide 3- 2
The Programming Process
• SE concepts require a rigorous and systematic
approach to software development called
software development life cycle
This video
Software Development Life Cycle & Code
Building programs
•Edit
•Compile
•Link
•Run
Software Development Life Cycle & Algorithm
e.g:
Flowchart -> C++ program
Algorithm is the steps
to solve problems
Software Development Life Cycle
• Problem Analysis
Identify data objects
Determine Input / Output data
Constraints on the problem
• Design
Decompose into smaller problems
Top-down design
Structured Chart
Develop Algorithm
Pseudocode
Flowchart
Software Development Life Cycle
• Implementation/coding/programming
Converting the algorithm into programming language
• Testing
Verify the program meets requirements
System and Unit test
• Maintenance
All programs undergo change over time
Input, Processing, and Output
Three steps that a program typically performs:
1) Gather input data:
• from keyboard
• from files on disk drives
2) Process the input data
3) Display the results as output:
• send it to the screen
• write to a file
Problem solving methods in this Class
Stop
Flowchart Symbol
Terminal: Used to indicates the start and end of a flowchart. Single flowline. Only one “Start”
and “Stop” terminal for each program. The end terminal for function/subroutine must use
“Return” instead of “Stop”.
Process: Used whenever data is being manipulated. One flowline enters and one flowline exits.
Input/Output: Used whenever data is entered (input) or displayed (output). One flowline enters
and one flowline exits.
Decision: Used to represent operations in which there are two possible selections. One flowline
enters and two flowlines (labelled as “Yes” and “No”) exit.
On-page Connector: Used to connect remote flowchart portion on the same page. One flowline
enters and one flowline exits.
Off-page Connector: Used to connect remote flowchart portion on different pages. One flowline
enters and one flowline exits.
Read A Input.
Read B Enter values for
A and B
Calculate Resut
C=A*B Process
Display the
Result C Output
Stop Terminal
Stop Program end
here
Example: Use of
comments/description
Start
Yes
No
Stop
Example: Use of connectors on the same page.
Start
1 2
2
Example: Use of connectors on the different page.
Page 1 Page 2
Start
2
1
Yes 1
No
Stop
2
The details (how the function works)
Example: Function-call example. we put in another flowchart.
This also known as
Note: Module = function = subroutine Function-Definition
Read
n1, n2 , n3
Body of a function is
AVRG (result, n1, n2,n3) the same with
normal flowchart
result = sum/3
At this part,
we only know what
we want to do. But we Print
result
don’t know how to do it
Stop
End terminal
must be “Return”
So now?
Read A
Read
ReadB &BH
Calculate Resut
C=A*B
Area, Ix & Iy
Display
Display the
Result
Area, Ix &CIy
Stop