Session 06
Session 06
Programming Fundamentals
SESSION 6 – ALGORITHM
College of Education
School of Continuing and Distance Education
2014/2015 – 2016/2017
Session Overview
• The design stage of the Program development
framework deals with the step by step instructions
required to solve the defined problem based on the
user requirements and program specification.
Algorithms, flowcharts and pseudo-codes are
discussed as tools for design in the imperative
paradigm. The success of programming effort and its
efficiency is largely due to the work done at the design
stage. Also, flowcharts and pseudo-codes are
introduced as design documentation tools of the
programmer.
Mr. Joseph Ecklu (DCS) Slide 2
Session Objectives
• Identify common algorithms
• Create algorithms for solving simple problems based
on program specification
• Be able to understand and apply algorithms to
problem solving as imperative design method
• Use flowcharts as pictorial representation of the
algorithm
• Write pseudo-codes
Input Data
Algorithm
A step-by-step method of solving a
problem or doing a task
Output Data
Mr. Joseph Ecklu (DCS) Slide 5
Example: Finding the largest integer among
five integers
(12, 8, 13, 9, 11) Input
Largest 12 12 8 13 9 11 List
Largest 12 12 8 13 9 11 List
Largest 13 12 8 13 9 11 List
Largest 13 12 8 13 9 11 List
Largest 13 12 8 13 9 11 List
Step 1 If the current integer is greater than Largest, set Largest to current integer
Step 5 If the current integer is greater than Largest, set Largest to current integer
Set largest to - ∞
Repeat the following steps
Largest Fig 3
Mr. Joseph Ecklu (DCS) Slide 9
CONSTRUCTS
• In structured programming or
algorithms, a program must be made
up of only three constructs
– Sequence
– Decision
– Repetition
Do action 1
Do action 2
…
Do action n
Action 1
FalseAction 1 TrueAction 1
Action 1 TrueAction 1
FalseAction 1 TrueAction 1
TrueAction 1
Action 1
Input a, b, c
Smallest = a
Is Yes
Smallest = b
b<smallest
No
A
Is Yes Smallest = c
c<smallest
No
Print smallest
Stop