Flowchart and Pseudocode(2)(2)(2)
Flowchart and Pseudocode(2)(2)(2)
Algorithms
Flowcharts
Pseudocode
• When you formulate a method/ procedure for solving a problem, it has to be computable.
• Such a procedure is called Algorithm.
5
Compare the two distances
Find the nearer location
Select the nearer one based on comparison result
General Notes:
• No strict rules
• Usually starts an operation sentence with a verb (description should be concise and precise)
Scenario 1: Flowchart 1
Start
End
NO
Select Is distance 1 Select
Select the nearer one based on Location 1 <= distance 2? Location 2
YES
the comparison result
End End
Start
Exit point
n increases by 1
1
Guidelines
2
3 • Write one statement per line only
• Capitalize the keywords
• Indent to show hierarchy
• End multi-line structures
• Keep statements programming-language independent
Flowchart
Start Pseudocode
Find the distance to location 1 FIND the distance to location 1
FIND the distance to location 2
Find the distance to location 2
IF distance1 < = distance2
Symbolize
SELECT Location 1
Select Is distance1 NO Select
Location 1 <= distance2? Location 2 ELSE
YES
SELECT Location 2
End END IF
Must be
unambiguous
Consider all
Every step must be Specify the order
possible decision points
clear and precise of steps precisely
[Branching and
[Sequence]
Looping]
Must terminate
(No matter which representation is used)
N
Are eggs ok? Stir the eggs
Decision blocks
Y
(make choices)
Any other Y
Add other ingredients
ingredients?
Output! N
Serve Scrambled Eggs
Can repeat
End
Answer No
Placeholder