Algorithms
IPO, Pseudo Code, and
Flow Charts
*
*
A chocolate chip cookie recipe requires the following ingredients:
• Baking Soda
• Salt
• Vanilla
• Hot Water
• Flour
• Chocolate chips
• Nuts
• Butter
• Granulated white sugar
• Brown sugar
Place the directions in the correct order ...
*
Directions placed in the correct order ...
[Link] oven to 350 degrees Fahrenheit.
[Link] together the butter, white sugar,
and brown sugar until smooth.
[Link] in the eggs one at a time, then stir
in the vanilla.
[Link] baking soda in hot water and
add to batter along with salt.
[Link] in flour, chocolate chips, and nuts.
[Link] by large spoonfuls onto ungreased
pans.
[Link] for about 10 minutes in the
preheated oven, or until edges are nicely
browned.
Why is the order of the above steps important?
*
What is an algorithm?
🞇 an algorithm is a sequence of
instructions used to accomplish a task
🞇 They are used to analyze and
breakdown complex problems before
coding begins
Think of algorithms like the blueprints an architect
designs before a building is constructed.
*
Why are algorithms
useful?
🞇 help programmers analyze how to
accomplish a task or solve a problem
🞇 make sure that all the necessary
instructions are included
🞇 instructions are placed in the correct order
🞇 can be used to write a program in any
programming language
🞇 Serves as good documentation for
programmers and non-programmers
*
Tools
🞇 The following three tools are commonly
used to analyze complex tasks or
problems:
🞇 IPO (Input, Process, Output) Chart
🞇 Pseudo Code
🞇 Flowchart
*
IPO Chart
🞇 An IPO Chart is a 3 column chart
Input Process Output
This is the This is the step- This is the result
information you by-step expected after
already have or instructions that the input has
must get to solve must be followed been processed.
the problem. to achieve the
result expected.
First fill in the Input column, then the Output
column and finally the Process column.
*
Area of a Rectangle
Input Process Output
• Length of the 1. Prompt user for the • Area of the
rectangle length of the rectangle in
• Width of the rectangle units squared.
rectangle 2. Prompt user for the
width of the
rectangle.
3. Multiple the length
by the width
4. Display area of the
rectangle in units
squared.
*
Pseudo Code
🞇 Pseudo code is a list of short and
consecutive English phrases used to
explain the steps required to accomplish
a task or solve a problem.
🞇 Major tasks are to be numbered with
whole numbers and subtasks with
decimal numbers.
Pseudo code can include keywords specific
to a programming language.
*
Area of a Rectangle
Input Process Output
• Length of the 1. Prompt user for the • Area of the
rectangle length of the rectangle in
• Width of the rectangle units squared.
rectangle 2. Prompt user for the
width of the
rectangle.
3. Multiple the length
by the width
4. Display area of the
rectangle in units
squared.
*
Flowcharts
🞇 A flowchart is drawn according to
defined rules
🞇 standard flowcharting symbols
prescribed by the American National
Standard Institute (ANSI)are used
*
Standard Symbols
Start / End Decision
On-Page
Process Connector Flow
Lines
Off-Page
Input/Output Connector
*
Flowcharting Guidelines
🞇 A flowchart should be clear, neat and easy
to follow
🞇 The direction of flow is usually from left to
right or top to bottom
🞇 Only one flow line should exit a Process
symbol
🞇 Only one flow line should enter a Decision
symbol
🞇 Never intersect flow lines
🞇 Ensure that the flowchart has a logical start
and finish
*
Area of a Rectangle
Start
Prompt
for
length
Promp
t for
width
Calculate Display
Area End
Area