Lec02-Problem Solving With Algorithm
Lec02-Problem Solving With Algorithm
5 Documentation
What is PDLC ?
1 Analysis All about the What.
• What the user wants from
the program?
2 Design • What is the input and
output of the program?
3 Development
Tasks Involved
• Gather user requirements
4 Testing
5 Documentation
What is PDLC ?
1 Analysis All about the How.
• How to fulfill what the user
wants?
2 Design • How the program is going
to achieve it?
3 Development
Tasks Involved
• Algorithm Design (using
4 Testing flowchart, pseudocode, or
other design tools.)
5 Documentation
What is PDLC ?
1 Analysis All about Code.
• Implement the algorithm
using programming
2 Design language(s)
Tasks Involved
3 Development
• Translate the algorithm
design into a programming
4 Testing language
5 Documentation
What is PDLC ?
1 Analysis All about Correctness.
• Test if the program does
what the user wants
2 Design correctly.
Tasks Involved
3 Development
• Check program’s output
and debug when needed.
4 Testing • Repeat Phase 1 if
enhancements are
required.
5 Documentation
What is PDLC ?
1 Analysis All about Recall.
• Ensure that programmers
able to recall what the
2 Design codes does in the future.
Tasks Involved
3 Development
• Generate written
documentations.
4 Testing • Improve source code
comments
5 Documentation
Algorithm
Representations
Algorithm Representations
How to represent or express algorithms?
Algorithm
Representation
Definition adopted from https://blog.usejournal.com/how-to-write-pseudocode-a-beginners-guide-29956242698 and C++ How to Program (8th Ed.) by Deitel and Deitel
Pseudocode: Examples
Example 1: Write a program that accepts an integer and outputs the
integer
Version 1:
INPUT an integer
OUTPUT the integer
Version 2:
INPUT X
OUTPUT X
Pseudocode: Examples
Example 2: Write a program calculating the sum of two integers
Version 1:
INPUT the first integer
INPUT the second integer
ADD the first integer and second integer, store result.
OUTPUT result
Version 2:
INPUT First
INPUT Second
Sum = First + Second
OUTPUT Sum
Flowchart
Flowchart
What do you understand
from the flowchart on
the right?
Get N
NOTE: “Get” or “Show” may be replaced with any word as long as it is unambiguous.
Flowchart: The Process Symbol
Indicates a particular operation.
In computing, this represents a CPU operation. The common ones
include: Variabl
e
Example 4:
Draw a flowchart that
calculates the sum of two
To be demonstrated
integers
live
Flowchart: Examples Start
Example 4:
Draw a flowchart that
calculates the sum of two
integers.
Flowchart: Common Symbols (Part
2)
Diagram Name Description
Output Output
“One” “Not One”
Start
Flowchart: Examples
Example 5:
Draw a flowchart that
accepts two integers and
To be demonstrated live
outputs the smallest.
Start
Flowchart: Examples
Example 5:
Draw a flowchart that
accepts two integers and
outputs the smallest.
Flowchart: Examples
Example 6:
Draw a flowchart that
accepts an integer.
Show “Zero” if the To be demonstrated live
integer is 0. Otherwise,
show “Positive” or
“Negative”, depending
on the sign of the
integer.
Flowchart: Examples
Example 6:
Draw a flowchart that
accepts an integer.
Show “Zero” if the
integer is 0. Otherwise,
show “Positive” or
“Negative”, depending
on the sign of the
integer.
Flowchart: Examples
Example 7:
Draw a flowchart that
shows “Hello”
infinitely. To be demonstrated live
Flowchart: Examples
Example 7:
Draw a flowchart that
shows “Hello”
infinitely.
Flowchart: Examples
Example 8:
Draw a flowchart that
shows “Hello” 100
times. To be demonstrated live
Flowchart: Examples
Example 8:
Draw a flowchart that
shows “Hello” 100
times.
Q&A
Acknowledgement
• This presentation has been designed using resources from
PoweredTemplate.com