Fp305 - Data Structure
Fp305 - Data Structure
Page 1
OVERVIEW OF ALGORITHM
ALGORITHM :
Algorithm is a set of steps for solving a particular problem using a certain method until the problem is solved. The word ALGORITHM is named as the name of Mathematician namely Al-Khawarizmi.
Page 2
OVERVIEW OF ALGORITHM
ii.
Page 3
OVERVIEW OF ALGORITHM
Page 4
OVERVIEW OF ALGORITHM
1. Pseudo Code
Pseudo code is a sequence of steps that are written using natural language processing expository involved in solving
problems.
The main purpose of presenting problem solving in a logical
and systematic.
Page 5
OVERVIEW OF ALGORITHM
ii.
Each step in problem solving are arranged one by one systematically. Each line of pseudo code represents a one-off measures implemented.
Page 6
OVERVIEW OF ALGORITHM
i.
Language statement
Algorithms written in natural language and has no specific regulations.
Page 7
OVERVIEW OF ALGORITHM
3. if necessary sugar
3.1. add sugar 4. if necessary cream 4.1 add cream 5. put hot water into the cup
Page 8
OVERVIEW OF ALGORITHM
Page 9
OVERVIEW OF ALGORITHM
a) Sequence structure:
1. beginning 2. step_1
3. step_2
: n. step_n n +1. end
Page 10
OVERVIEW OF ALGORITHM
n.2. step_n.2
: nn step_n.n
Page 11
OVERVIEW OF ALGORITHM
c) Structure jump:
n. move to the n
d) Repeat structure:
n. go to step before the n
Page 12
OVERVIEW OF ALGORITHM
ii.
Page 13
OVERVIEW OF ALGORITHM
a) Sequence structure:
begin 1. beginning
2. step_1
3. step_2 : n. step_n n +1. end
Page 14
OVERVIEW OF ALGORITHM
else
code block is not true End if
Page 15
OVERVIEW OF ALGORITHM
c) Struktur ulangan:
repeat bhg_yg_perlu diulang
until syarat
Page 16
OVERVIEW OF ALGORITHM
End while
Page 17
OVERVIEW OF ALGORITHM
Example: an algorithm for preparing a cup of coffee using programming language similar to language statement
Page 18
OVERVIEW OF ALGORITHM
begin add a cup of coffee if necessary sugar then add sugar end if if necessary cream then add cream
end if
put hot water into the cup end
Page 19
OVERVIEW OF ALGORITHM
i.
ii.
Sequence
Choice
Page 20
OVERVIEW OF ALGORITHM
2. Flow Chart
Flow chart consisting of boxes containing various forms to indicate the operation to be done and the arrows to specify the sequence of
operations.
Page 21
OVERVIEW OF ALGORITHM
End Terminator
Page 22
OVERVIEW OF ALGORITHM
A 3
Decision
Off-page connector
Page 23
OVERVIEW OF ALGORITHM
Input
Storage
Page 24
OVERVIEW OF ALGORITHM
Boil a water
25
Page 25
OVERVIEW OF ALGORITHM
26
Add sugar
Yes
Need sugar?
No Need creamer? Yes Add creamer
No
Put the hot water
End
Page 26
OVERVIEW OF ALGORITHM
i.
ii.
Page 27
OVERVIEW OF ALGORITHM
algorithm are :
i. ii. Running time Use of memory space
Page 28
EXERCISES
1. There is a program which will receive a pair of input numbers and print the message "SAME" if the two numbers
Page 29
EXERCISES
i.
ii.
Write
an
algorithm
using
pseudo
code
in
language
Page 30
EXERCISES
2. 3. 4.
Page 31