SlideShare a Scribd company logo
1 of 40
Download to read offline
04/10/2014
1
Algoritma dan Flowchart
Angga Akbar Fanani
1
Problem
ā€¢ Pertanyaan atau tugas yang kita cari jawaban
dan/atau penyelesaiannya
2
We "just do" Guesswork-
and-luck
Experience
(possibly
someoneelse's)
Trial-and-error Scientifically"
HOW DO WE SOLVE PROBLEMS?
04/10/2014
2
The Problem-solving Process
3
Problemspecification
Algorithm
Program
Executable (solution)
Design
Implementation
Compilation
Analysis
The Problem-solving Process
Problem specification
Algorithm
Program
Executable (solution)
Analysis
Design
Implementation
Compilation
ā€œDoctor, my head hurtsā€œ
Patient has elevated pressure in
anterior parietal lobe
1. Sterilize cranial saw
2. Anaesthetize patient
3. Remove top of skull
4. Get the big spoon...
5. etc., etc.
sterilize(saw,alcohol);
raise_hammer();
lower hammer(fast);
start(saw);
/* etc. etc. */
0100111010110010101010101001010101010100
11001010101010100101101001110101010101
00100101110100111101010101111101010100
0110100001101...
4
04/10/2014
3
5
Definisi Algoritma
ā€¢ Algoritma adalah urutan langkah logis tertentu
untuk memecahkan suatu masalah
ā–« Urutan langkah logis, yang berarti algoritma harus
mengikuti suatu urutan tertentu, tidak boleh
melompat-lompat
ā€¢ Alur pemikiran dalam menyelesaikan suatu
pekerjaan yang dituangkan secara tertulis.
ā–« Alur pikiran, sehingga algoritma seseorang dapat
juga berbeda dari algoritma orang lain
ā–« Tertulis, yang artinya dapat berupa kalimat,
gambar, atau tabel tertentu
6
04/10/2014
4
Definisi Algoritma
ā€¢ Deretan langkah-langkah komputasi yang
mentransformasikan data masukan menjadi
keluaran
ā€¢ Deretan instruksi yang jelas untuk memecahkan
masalah, yaitu untuk memperoleh keluaran yang
diinginkan dari suatu masukan dalam jumlah waktu
yang terbatas
ā€¢ Prosedur komputasi yang terdefinisi dengan baik
yang menggunakan beberapa nilai sebagai masukan
dan menghasilkan beberapa nilai yang disebut
keluaran.
7
Sejarah Algoritma
ā€¢ Asal kata algoritma berasal dari nama Abu Jaā€™far
Mohammed Ibn Musa al-Khowarizmi
ā–« Ilmuan Persia yang menulis kitab al jabar wal-
muqabala (the book of restoration and reduction)
ā–« Tahun 825 M
ā€¢ Perubahan kata
ā–« Algorism ļƒ  proses menghitung dengan angka Arab
ā–« Algorist ļƒ  orang yang menggunakan angka Arab
ā–« Algorithm ļƒ  metode perhitungan secara umum
ā€¢ Tahun 1950 ļƒ  euclidā€™s algorithm
ā–« Langkah-langkah menemukan pembagi bersama
terbesar (common greatest divisor = gcd)
8
04/10/2014
5
Ciri Algoritma (Donald E. Knuth)
ā€¢ Finiteness: Algoritma harus berhenti setelah
mengerjakan sejumlah langkah terbatas
ā€¢ Definiteness: Setiap langkah harus didefinisikan
secara tepat dan tidak berarti-dua (ambiguous)
ā€¢ Algoritma memiliki nol atau lebih masukan (input)
ā€¢ Algoritma memiliki nol atau lebih keluaran (output)
ā€¢ Effectiveness: Algoritma harus efektif, setiap
langkah harus sederhana sehingga dapat dikerjakan
dalam sejumlah waktu yang masuk akal
9
Algorithm -- Examples
ā€¢ A cooking recipe
ā€¢ Assembly instructions for a model
ā€¢ The rules of how to play a game
ā€¢ VCR instructions
ā€¢ Description of a martial arts technique
ā€¢ Directions for driving from A to B
ā€¢ A knitting pattern
ā€¢ A car repair manual
10
04/10/2014
6
Almond and Honey Slice
1/2 quantity Shortcrust Pastry
185 g unsalted butter
100 g castor sugar
5 tablespoonshoney
50 ml cream
50 ml brandy or any other
liqueuror spirit
300 g flaked almonds
Preheat oven for 200Ā° C
Line a 30 cm ļ‚“ 20 cm baking tray
with baking paper, and then with
pastry
Bake blind for 20 minutes, then
remove weights and foil
Turn oven up to 220Ā° C.
Bring remaining ingredients to a
boil, stirring.
Spread evenly over pastry.
Bake until topping is bubblingand
has caramelised evenly, about 15
minutes.
Cool before cuttinginto fingers or
squares.
11
From:Stephanie Alexander, The
Cookā€™s Companion, Viking/Penguin,
Ringwood, Victoria,1996, p. 349.
Almond and Honey Slice
1/2 quantity Shortcrust Pastry
185 g unsalted butter
100 g castor sugar
5 tablespoonshoney
50 ml cream
50 ml brandy or any other
liqueuror spirit
300 g flaked almonds
Preheat oven for 200Ā° C
Line a 30 cm ļ‚“ 20 cm baking tray
with baking paper, and then with
pastry
Bake blind for 20 minutes, then
remove weights and foil
Turn oven up to 220Ā° C.
Bring remaining ingredients to a
boil, stirring.
Spread evenly over pastry.
Bake until topping is bubblingand
has caramelised evenly, about 15
minutes.
Cool before cuttinginto fingers or
squares.
12
From:Stephanie Alexander, The
Cookā€™s Companion, Viking/Penguin,
Ringwood, Victoria,1996, p. 349.
Instructions are given
in the order in which
they are performed
(ā€œexecutedā€)
04/10/2014
7
Correct Algorithm?
Cut chicken into pieces
and brown the pieces on
all sides in a casserole
dish in hot olive oil.
Remove the chicken and to
the juices in the
casserole add garlic,
onions and green
peppers, and sautƩ until
onion is golden.
Add bay leaf, whole
tomatoes, and chicken
broth.
When the broth boils add
salt, saffron and rice.
Arrange chicken on rice, cover
casserole and bake in a
moderate oven (350Ā°F) for
20 minutesor until the rice
is tender.
Add beans and artichokes
during last 10 minutesof
cooking.
13
From: ā€œArroz Con Polloā€ in The
Margaret Fulton Cookbook,
Hamlyn, Sydney, 1968.
Correct Algorithm?
Cut chicken into pieces
and brown the pieces on
all sides in a casserole
dish in hot olive oil.
Remove the chicken and to
the juices in the
casserole add garlic,
onions and green
peppers, and sautƩ until
onion is golden.
Add bay leaf, whole
tomatoes, and chicken
broth.
When the broth boils add
salt, saffron and rice.
Arrange chicken on rice, cover
casserole and bake in a
moderate oven (350Ā°F) for
20 minutesor until the rice
is tender.
Add beans and artichokes
during last 10 minutesof
cooking.
14
From: ā€œArroz Con Polloā€ in The
Margaret Fulton Cookbook,
Hamlyn, Sydney, 1968.
04/10/2014
8
Correct Algorithm?
Cut chicken into pieces
and brown the pieces on
all sides in a casserole
dish in hot olive oil.
Remove the chicken and to
the juices in the
casserole add garlic,
onions and green
peppers, and sautƩ until
onion is golden.
Add bay leaf, whole
tomatoes, and chicken
broth.
When the broth boils add
salt, saffron and rice.
Arrange chicken on rice, cover
casserole and bake in a
moderate oven (350Ā°F) for 10
minutes.
Add beans and artichokes.
Cover, and bake for another 10
minutesor until rice is
tender.
15
Correct algorithm ???...
16
04/10/2014
9
Correct algorithm
17
Values
ā€¢ Represent quantities, amounts or measurements
ā€¢ May be numerical or alphabetical
(or other things)
ā€¢ Often have a unit related to their purpose
ā€¢ Example:
ā–« Recipe ingredients
18
04/10/2014
10
Variables
ā€¢ Are containers for values ā€“ places to store
values
ā€¢ Example:
19
This jar
can contain
10 cookies
50 grams of sugar
3 slices of cake
etc.
Values
Variable
Restrictions on Variables
ā€¢ Variables may be restricted to contain a specific
type of value
20
04/10/2014
11
Instructions (Primitives)
ā€¢ Some action that is
ā–« simple
ā–« unambiguous
ā–« that the system knows about...
ā–« ...and should be able to actually do
21
Instructions ā€“ Examples
ā€¢ Take off your shoes
ā€¢ Count to 10
ā€¢ Cut along dotted line
ā€¢ Knit 1
ā€¢ Purl 2
ā€¢ Pull rip-cord firmly
ā€¢ Sift 10 grams of arsenic
22
Directions to perform
specific actions on values
and variables
04/10/2014
12
Instructions -- Application
ā€¢ Some instructions can only be applied to a
specific type of values or variables
ā€¢ Examples:
23
Instructions (Primitives) --
Recommendations
ā€¢ When writing an algorithm, make each
instruction simple and unambiguous
ā€¢ Example:
24
Cut chicken into pieces and
brown the pieces on all
sides in a casserole dish
in hot olive oil.
Cut chicken into pieces.
Heat olive oil in a casserole
dish.
Brown the chicken pieces in
the casserole dish.
04/10/2014
13
Instructions (Primitives)
ā€¢ When writing an algorithm, make each
instruction simple and unambiguous
ā€¢ Example:
25
Cut chicken into pieces and
brown the pieces on all
sides in a casserole dish
in hot olive oil.
Cut chicken into pieces.
Heat olive oil in a casserole
dish.
Brown the chicken pieces in
the casserole dish.
A ā€œsequenceā€ of
simple instructions
Function
ā€¢ A named sequence of instructions
ā€¢ So that you can
ā–« Refer to it collectively (by name)
ā–« ...instead of individually (by each instruction in the
sequence)
ā€¢ Example:
ā–« Drive_To_Uni
26
04/10/2014
14
Function -- Example
function Drive_To_Uni
{
1. find car keys
2. disable car alarm
3. open car door
4. get in car
5. shut car door
6. put keys in ignition
7. start car
8. back car out of
driveway
9. drive to end of street
10. turn right
11. drive to end of street
12. turn left
...etc...etc...etc
27
...etc...etc...etc...
52. find parking space
53. pull into parking
space
54. turn off engine
55. remove keys from
ignition
56. open car door
57. get out
58. shut car door
59. lock car door
60. enable alarm
}
Function ā€“ Example
function Do_Wednesday
{
Wake_up
Have_Shower
Eat_Breakfast
Drive_To_Uni
Sit_1301_Lecture
...etc...etc...etc...
Drive_From_Uni
...etc...etc...etc...
}
function Do_Week
{
Do_Monday
Do_Tuesday
Do_Wednesday
Do_Thursday
...etc...etc...etc...
}
28
04/10/2014
15
Components of an Algorithm
ā€¢ Variables and values
ā€¢ Instructions
ā–« Sequences
ā–« Functions
ā–« Selections
ā–« Repetitions
Also required: Documentation
29
Struktur dasar algoritma
Struktur Urut (Sequence),
Struktur Pemilihan
(Selection),
Struktur Pengulangan
(Repetition).
30
04/10/2014
16
Sequence
ā€¢ A series of instructions
ā€¢ ...to be carried out one after the other...
ā€¢ ...without hesitation or question
ā€¢ Example:
ā–«How to cook a Gourmet MealTM
31
Sequence -- Example
1. Open freezer door
2. Take out Gourmet Mealā„¢
3. Close freezer door
4. Open microwave door
5. Put Gourmet Mealā„¢ on carousel
6. Shut microwave door
7. Set microwave on high for 5 minutes
8. Start microwave
9. Wait 5 minutes
10.Open microwave door
11.Remove Gourmet Mealā„¢
12.Close microwave door
32
04/10/2014
17
Struktur Urut (Sequence)
ā€¢ suatu strukturprogram dimana setiap
baris program akan dikerjakan secara urut
dari atas ke bawah sesuai dengan urutan
penulisannya.
ā€¢ instruksibaris program 2 akan dikerjakan
jika instruksi baris program 1 telah selesai
dikerjakan.
33
Selection
ā€¢ An instruction that decides which of two
possible sequences is executed
ā€¢ The decision is based on a single true/false
condition
ā€¢ Examples:
ā–« Car repair
ā–« Reciprocals
34
04/10/2014
18
Selection Example ā€“ Car Repair
if (motor turns)
then
{
CheckFuel
CheckSparkPlugs
CheckCarburettor
}
else
{
CheckDistributor
CheckIgnitionCoil
}
35
Selection Example ā€“ Car Repair
if (motor turns)
then
{
CheckFuel
CheckSparkPlugs
CheckCarburettor
}
else
{
CheckDistributor
CheckIgnitionCoil
}
36
Should be a
true or false
condition
04/10/2014
19
Selection Example ā€“ Car Repair
if (motor turns)
then
{
CheckFuel
CheckSparkPlugs
CheckCarburettor
}
else
{
CheckDistributor
CheckIgnitionCoil
}
37
Sequence if
the condition
is true
Selection Example ā€“ Car Repair
if (motor turns)
then
{
CheckFuel
CheckSparkPlugs
CheckCarburettor
}
else
{
CheckDistributor
CheckIgnitionCoil
}
38
Sequence if the
condition is
false
04/10/2014
20
Struktur Pemilihan (Selection),
ā€¢ Menghasilkan nilai benar (true) atau nilai salah
(false).
ā€¢ IF sederhana
ļ‚– IF <syarat> THEN
<instruksi>
ā€¢ Pada bentuk IF sederhana ini,
intruksi akan dikerjakan jika
syarat yangdiuji benilai benar (true). Jika syarat
yang diuji benilai salah (false) maka tidak ada
instruksi yang dikerjakan.
39
IF ā€¦ THEN ā€¦ ELSE ā€¦
ā€¢ IF <syarat> THEN
<instruksi1>
ELSE
<instruksi2>
ā€¢ Pada bentuk ini terdapat dua
kemungkinan pilihan yang
akan dikerjakan berdasarkan
hasil pengujian, jika syarat
yang diuji benilai benar maka instruksi1 yang
dikerjakan, dan jika syarat yang diuji bernilai
salah maka instruksi2 yang dikerjakan.
40
04/10/2014
21
IF Bersarang (Nested IF)
ā€¢ IF <syarat1> THEN
<instruksi1>
ā€¢ ELSE IF <syarat2> THEN
<instruksi2>
ā€¢ ELSE IF <syarat3> THEN
<instruksi3>
ā€¢ ELSE IF <syaratm> THEN
<instruksim>
ā€¢ ELSE
<Instruksin>
41
Repetition
ā€¢ Repeat an instruction...
ā–« ...while (or maybe until) some true or
false condition occurs
ā–« Test the condition each time before
repeating the instruction
ā€¢ Also known as iteration or loop
ā€¢ Example:
ā–« Algorithm for getting a date
42
04/10/2014
22
Repetition ā€“ Example
function AskOnDate ( name, time, location )
{
Phone(name)
Say("Hey", name, "it's your lucky day!")
Say("Wanna come to", location, "at", time,
"?")
ListenToReply ( )
start begging count at zero
while (reply is "No" and begging count < 100)
{
Say("Oh please!")
add 1 to begging count
ListenToReply ( )
}
}
43
Repetition ā€“ Example (cont)
function AskOnDate ( name, time, location )
{
Phone(name)
Say("Hey", name, "it's your lucky day!")
Say("Wanna come to", location, "at", time,
"?")
ListenToReply ( )
start begging count at zero
while ( reply is "No" and begging count < 100 )
{
Say("Oh please!")
add 1 to begging count
ListenToReply ( )
}
}
44
Condition is tested
before sequence
04/10/2014
23
Repetition ā€“ Example (cont)
function AskOnDate ( name, time, location )
{
Phone(name)
Say("Hey", name, "it's your lucky day!")
Say("Wanna come to", location, "at", time, "?")
ListenToReply ( )
start begging count at zero
while (reply is "No" and begging count < 100)
{
Say("Oh please!")
add 1 to begging count
ListenToReply ( )
}
}
45
Sequence may not
get executed at all
Repetition ā€“ Example (cont)
function AskOnDate ( name, time, location )
{
Phone(name)
Say("Hey", name, "it's your lucky day!")
Say("Wanna come to", location, "at", time, "?")
ListenToReply ( )
start begging count at zero
while (reply is "No" and begging count < 100)
{
Say("Oh please!")
add 1 to begging count
ListenToReply ( )
}
}
46
Ensure initial
values of variables
used in the
conditions are set
correctly
04/10/2014
24
Repetition ā€“ Example (cont)
function AskOnDate ( name, time, location )
{
Phone(name)
Say("Hey", name, "it's your lucky day!")
Say("Wanna come to", location, "at", time,
"?")
ListenToReply ( )
start begging count at zero
while (reply is "No" and begging count < 100)
{
Say("Oh please!")
add 1 to begging count
ListenToReply ( )
}
}
47
Ensure the variables
used in the conditions
are updated in each
repetition
Repetition ā€“ Example (cont)
function AskOnDate ( name, time, location )
{
Phone(name)
Say("Hey", name, "it's your lucky day!")
Say("Wanna come to", location, "at", time,
"?")
ListenToReply ( )
start begging count at zero
while (reply is "No" and begging count < 100)
{
Say("Oh please!")
}
}
48
Infinite loop
ā€¢ What if we donā€™t increment the begging count?
04/10/2014
25
Struktur pengulangan repetition
ā€¢ Struktur for
ā€¢ Mengulangsatu baris
instruksiatau satu blok
instruksisampai jumlah
perulanganyang
disyaratkanterpenuhi.
ā€¢ Ciri utama terdapatnilai
awaldan nilai akhir yang
menunjukkanbanyaknya
pengulanganyang akan
dilakukan.
49
Struktur while
ā€¢ untukmengulangsatu baris instruksi atau
satu blok baris instruksi selama syarat
yang diberikan masih terpenuhi.
ā€¢ Syarat akan diuji didepan.
ā€¢ Jika syarat yang diuji bernilai benar maka
instruksi1,instruksi2, instruksi3 akan
dikerjakan, setelah mengerjakan
instruksi1, instruksi2, instruksi3 maka
syarat akan diuji lagi.
ā€¢ pengulangan akan berhentijika syarat
yang diuji bernilai salah.
50
04/10/2014
26
Struktur do ā€¦ while
ā€¢ mengulangsatu baris instruksi
atau satu blok baris instruksi
sampai syarat tidak terpenuhi.
ā€¢ syarat akan diuji dibelakang,
sehinggabaris instruksi yang
masukdalam blok doā€¦while
minimal akan dikerjakan satu
sekali.
51
Documentation
ā€¢ Records what the algorithm does
ā€¢ Describes how it does it
ā€¢ Explains the purpose of each component of the
algorithm
ā€¢ Notes restrictions or expectations
ā€¢ Example:
ā–« Getting a date (again)
52
04/10/2014
27
Documentation -- Example
Think of something romantic to do
decide on time and location
Work through address book to look for a
person
initialise booking to ā€œunsuccessfulā€
until (successfully booked)
{
get next Name in little black book
AskOnDate(Name, Time, Location)
DetermineBookingSuccess
}
Assumes that I will find someone in the book
before it runs out
SighWithRelief
53
From Algorithms to Programs
54
Problem
Program
Program
Algorithm
Algorithm: A sequence of
instructions describing how to do a
task (or process)
04/10/2014
28
The Software Development Process
ā€¢ Define the problem clearly
ā€¢ Analyse the problem thoroughly
ā€¢ Design an algorithm carefully
ā€¢ Code the algorithm efficiently
ā€¢ Test the code thoroughly
ā€¢ Document the system lucidly
55
Top-down Algorithm Design
ā€¢ Write down what you have to do
ā€¢ Break that into 3-7 smaller steps
ā€¢ Break each step into 3-7 smaller steps
ā€¢ Keeping subdividing until each individual
step is easy enough to do
ā€¢ Example:
ā–« Learning
56
04/10/2014
29
Top-down Design -- Example
57
Learn
Prepare
Study
Reinforce
Read
Make notes
Prepare questions
Attend lecture
Listen and think
Complete prac
Attend tute
Record answers to
questions
Revise notes
Read lecture notes
Read textbook
Read exercise
Design algorithm
Code solution
Test and document
Record insights
Cara Penyajian Algoritma
ā€¢ Uraian Deskriptif
ā–« Menggunakan bahasa yang bisa di gunakan sehari-
hari
ā€¢ Menggunakan flow chart (diagram alir)
ā€¢ Menggunakan pseudo-code
ā–« Ditulis dalam kode-kode yang disepakati yang
mempunyai arti
58
04/10/2014
30
59
Algoritma dan Flowchart
ā€¢ Algoritma merupakan urutan langkah logika
pemikiran detail yang diperlukan untuk
memecahkan masalah.
ā€¢ Algoritma dapat direpresentasikan dalam format
grafis yang disebut flowchart atau diagram
alir.
ā€¢ Flowchart juga dapat digunakan untuk
menggambarkan aliran urutan program
60
04/10/2014
31
Bagan-bagan Flowchart
ā€¢ Terminal
ā–« Bentuk : rounded rectangle
ā–« Mengindikasikan titik awal atau akhir
61
Bagan-bagan Flowchart
ā€¢ Connector
ā–« Bentuk : circle
ā–« Mengindikasikan titik penghubung ke bagan lain yang
terputus dalam satu halaman karena terlalu jauh atau
memungkinkan memotong garis panah lain
62
04/10/2014
32
Bagan-bagan Flowchart
ā€¢ Connector
ā–« Bentuk : pentagon
ā–« Mengindikasikan titik penghubung ke bagan lain yang
terputus karena beda halaman
63
Bagan-bagan Flowchart
ā€¢ Preparation atau initialization
ā–« Bentuk : hexagon
ā–« Mengindikasikan tahap awal pemrograman (misalnya
mendeklarasikan variabel, mengidentifikasikan nilai
awal konstanta atau variabel)
64
04/10/2014
33
Bagan-bagan Flowchart
ā€¢ Data
ā–« Bentuk : parallelogram
ā–« Mengindikasikan masukan atau keluaran data
65
Bagan-bagan Flowchart
ā€¢ Process
ā–« Bentuk : rectangle
ā–« Mengindikasikan proses komputasi
66
04/10/2014
34
Bagan-bagan Flowchart
ā€¢ Predefined/Nested Process (Subroutine)
ā–« Bentuk : rectangle
ā–« Mengindikasikan proses komputasi
67
Bagan-bagan Flowchart
ā€¢ Manual Operation
ā–« Bentuk : trapezoid
ā–« Mengindikasikan operasi yang dilakukan secara
manual
68
04/10/2014
35
Bagan-bagan Flowchart
ā€¢ Manual Input
ā–« Bentuk : trapezoid
ā–« Mengindikasikan masukan manual menggunakan
input device (misalnya keyboard, mouse, bar code
reader, imaging device)
69
Bagan-bagan Flowchart
ā€¢ Card
ā–« Bentuk : chamfered rectangle
ā–« Mengindikasikan penggunaan card reader (misalnya
punched card reader ataupun memory card reader)
70
04/10/2014
36
Bagan-bagan Flowchart
ā€¢ Database atau Repository
ā–« Bentuk : drum
ā–« Mengindikasikan penggunaan media penyimpanan
basisdata
71
Bagan-bagan Flowchart
ā€¢ Display
ā–« Bentuk : CRT Symbol
ā–« Mengindikasikan proses penampilan informasi untuk
dibaca atau dilihat user di layar monitor atau projector
72
04/10/2014
37
Bagan-bagan Flowchart
ā€¢ Report
ā–« Bentuk : Sheet
ā–« Mengindikasikan proses pencetakan laporan untuk
dibaca atau dilihat user menggunakan printer atau
plotter
73
Bagan-bagan Flowchart
ā€¢ Annotation
ā–« Bentuk : Arrow
ā–« Mengindikasikan hubungan presedensi antar operasi
atau alur urutan operasi
74
04/10/2014
38
Bagan-bagan Flowchart
ā€¢ Decision
ā–« Bentuk : diamond
ā–« Mengindikasikan pencabangan alternatif operasi
dengan pengambilan keputusan berdasarkan kriteria
atau kondisi
75
Decision / Condition Structure
76
YES
NO
YES
NO
YES
NO
YES
NO
04/10/2014
39
Repetition / Recursive Structure
77
YES
NO
YES
NO
Metodologi Pengembangan Program
78
Mulai
Analisis Domain
Masalah
Merumuskan
Algoritma
Semua
Skenario
Tertulis ?
Mapping
Flowchart
Struktur
Logika
Sesuai ?
Verify
Program Code
Identifier,
Syntax,
Semantic ?
Debug
Listing Program
Compile
Machine Code
Compile
Berhasil
?
Eksekusi
Program
Eksekusi
Berhasil
?
Keluaran
Program
Sesuai ?
Eksekusi
Program
Selesai
04/10/2014
40
Contoh Algoritma
ļ‚¢Step 1: Turn the stereo on.
ļ‚¢Step 2: If the band is set to FM, switch it to AM.
ļ‚¢Step 3: If the station is set to a station greater
than 610, turn the station to the left until 610 is
reached.
ļ‚¢Step 4: If the station is set to a station less than
610, turn the station to the right until 610 is
reached.
ļ‚¢Step 5: Listen to the best sports talk station in
the country.
79
80
Contoh Flowchart

More Related Content

Similar to Algoritma Dan Flowchart HOW DO WE SOLVE PROBLEMS

Final Presentation Censored
Final Presentation CensoredFinal Presentation Censored
Final Presentation CensoredNicole Jax
Ā 
Spanish food for our Multicultural breakfast.
Spanish food for our Multicultural breakfast. Spanish food for our Multicultural breakfast.
Spanish food for our Multicultural breakfast. iesfranciscomontoya
Ā 
Procedure text.pptx
Procedure text.pptxProcedure text.pptx
Procedure text.pptxZakiAufa2
Ā 
100+ Classic French Recipes .PDF
100+ Classic French Recipes .PDF100+ Classic French Recipes .PDF
100+ Classic French Recipes .PDFMiggy
Ā 
Our favourite recipes
Our favourite recipesOur favourite recipes
Our favourite recipescharoyvan
Ā 
Recetas
RecetasRecetas
Recetasrio_piles
Ā 
Rubric WorksheetInternship Portfolio ProjectDoes Not M.docx
Rubric WorksheetInternship Portfolio ProjectDoes Not M.docxRubric WorksheetInternship Portfolio ProjectDoes Not M.docx
Rubric WorksheetInternship Portfolio ProjectDoes Not M.docxSUBHI7
Ā 
Cooking Step by Step
Cooking Step by StepCooking Step by Step
Cooking Step by StepReading Seed
Ā 
Perfect Pie Bake 101- Achatz Handmade Pie Company
Perfect Pie Bake 101- Achatz Handmade Pie Company Perfect Pie Bake 101- Achatz Handmade Pie Company
Perfect Pie Bake 101- Achatz Handmade Pie Company Jill Christoff
Ā 
Keto cream cheese clouds
Keto cream cheese cloudsKeto cream cheese clouds
Keto cream cheese cloudsAdam Alhajdawood
Ā 
Our favourite recipes by 6th grade
Our favourite recipes by 6th grade Our favourite recipes by 6th grade
Our favourite recipes by 6th grade antoniotheteacher
Ā 

Similar to Algoritma Dan Flowchart HOW DO WE SOLVE PROBLEMS (20)

Final Presentation Censored
Final Presentation CensoredFinal Presentation Censored
Final Presentation Censored
Ā 
Spanish food for our Multicultural breakfast.
Spanish food for our Multicultural breakfast. Spanish food for our Multicultural breakfast.
Spanish food for our Multicultural breakfast.
Ā 
Treball vicent ferrer 4t b
Treball vicent ferrer 4t bTreball vicent ferrer 4t b
Treball vicent ferrer 4t b
Ā 
Treball vicent ferrer 4t b
Treball vicent ferrer 4t bTreball vicent ferrer 4t b
Treball vicent ferrer 4t b
Ā 
Treball vicent ferrer 4t b
Treball vicent ferrer 4t bTreball vicent ferrer 4t b
Treball vicent ferrer 4t b
Ā 
Procedure text.pptx
Procedure text.pptxProcedure text.pptx
Procedure text.pptx
Ā 
100+ Classic French Recipes .PDF
100+ Classic French Recipes .PDF100+ Classic French Recipes .PDF
100+ Classic French Recipes .PDF
Ā 
Our favourite recipes
Our favourite recipesOur favourite recipes
Our favourite recipes
Ā 
Ecooking recipe book
Ecooking recipe bookEcooking recipe book
Ecooking recipe book
Ā 
Ecooking recipe book
Ecooking recipe bookEcooking recipe book
Ecooking recipe book
Ā 
Lecture 5
Lecture 5Lecture 5
Lecture 5
Ā 
Recetas
RecetasRecetas
Recetas
Ā 
Recetas
RecetasRecetas
Recetas
Ā 
Rubric WorksheetInternship Portfolio ProjectDoes Not M.docx
Rubric WorksheetInternship Portfolio ProjectDoes Not M.docxRubric WorksheetInternship Portfolio ProjectDoes Not M.docx
Rubric WorksheetInternship Portfolio ProjectDoes Not M.docx
Ā 
Ch10pp
Ch10ppCh10pp
Ch10pp
Ā 
Cooking Step by Step
Cooking Step by StepCooking Step by Step
Cooking Step by Step
Ā 
Perfect Pie Bake 101- Achatz Handmade Pie Company
Perfect Pie Bake 101- Achatz Handmade Pie Company Perfect Pie Bake 101- Achatz Handmade Pie Company
Perfect Pie Bake 101- Achatz Handmade Pie Company
Ā 
Keto cream cheese clouds
Keto cream cheese cloudsKeto cream cheese clouds
Keto cream cheese clouds
Ā 
Our favourite recipes by 6th grade
Our favourite recipes by 6th grade Our favourite recipes by 6th grade
Our favourite recipes by 6th grade
Ā 
Cookery 2
Cookery 2Cookery 2
Cookery 2
Ā 

More from Jeff Nelson

Pin By Rhonda Genusa On Writing Process Teaching Writing, Writing
Pin By Rhonda Genusa On Writing Process Teaching Writing, WritingPin By Rhonda Genusa On Writing Process Teaching Writing, Writing
Pin By Rhonda Genusa On Writing Process Teaching Writing, WritingJeff Nelson
Ā 
Admission Essay Columbia Suppl
Admission Essay Columbia SupplAdmission Essay Columbia Suppl
Admission Essay Columbia SupplJeff Nelson
Ā 
001 Contractions In College Essays
001 Contractions In College Essays001 Contractions In College Essays
001 Contractions In College EssaysJeff Nelson
Ā 
016 Essay Example College Level Essays Argumentativ
016 Essay Example College Level Essays Argumentativ016 Essay Example College Level Essays Argumentativ
016 Essay Example College Level Essays ArgumentativJeff Nelson
Ā 
Sample Dialogue Of An Interview
Sample Dialogue Of An InterviewSample Dialogue Of An Interview
Sample Dialogue Of An InterviewJeff Nelson
Ā 
Part 4 Writing Teaching Writing, Writing Process, W
Part 4 Writing Teaching Writing, Writing Process, WPart 4 Writing Teaching Writing, Writing Process, W
Part 4 Writing Teaching Writing, Writing Process, WJeff Nelson
Ā 
Where To Find Best Essay Writers
Where To Find Best Essay WritersWhere To Find Best Essay Writers
Where To Find Best Essay WritersJeff Nelson
Ā 
Pay Someone To Write A Paper Hire Experts At A Cheap Price Penessay
Pay Someone To Write A Paper Hire Experts At A Cheap Price PenessayPay Someone To Write A Paper Hire Experts At A Cheap Price Penessay
Pay Someone To Write A Paper Hire Experts At A Cheap Price PenessayJeff Nelson
Ā 
How To Write A Argumentative Essay Sample
How To Write A Argumentative Essay SampleHow To Write A Argumentative Essay Sample
How To Write A Argumentative Essay SampleJeff Nelson
Ā 
Buy Essay Buy Essay, Buy An Essay Or Buy Essays
Buy Essay Buy Essay, Buy An Essay Or Buy EssaysBuy Essay Buy Essay, Buy An Essay Or Buy Essays
Buy Essay Buy Essay, Buy An Essay Or Buy EssaysJeff Nelson
Ā 
Top Childhood Memory Essay
Top Childhood Memory EssayTop Childhood Memory Essay
Top Childhood Memory EssayJeff Nelson
Ā 
Essay About Teacher Favorite Songs List
Essay About Teacher Favorite Songs ListEssay About Teacher Favorite Songs List
Essay About Teacher Favorite Songs ListJeff Nelson
Ā 
Free College Essay Sample
Free College Essay SampleFree College Essay Sample
Free College Essay SampleJeff Nelson
Ā 
Creative Writing Worksheets For Grade
Creative Writing Worksheets For GradeCreative Writing Worksheets For Grade
Creative Writing Worksheets For GradeJeff Nelson
Ā 
Kindergarden Writing Paper With Lines 120 Blank Hand
Kindergarden Writing Paper With Lines 120 Blank HandKindergarden Writing Paper With Lines 120 Blank Hand
Kindergarden Writing Paper With Lines 120 Blank HandJeff Nelson
Ā 
Essay Writing Rubric Paragraph Writing
Essay Writing Rubric Paragraph WritingEssay Writing Rubric Paragraph Writing
Essay Writing Rubric Paragraph WritingJeff Nelson
Ā 
Improve Essay Writing Skills E
Improve Essay Writing Skills EImprove Essay Writing Skills E
Improve Essay Writing Skills EJeff Nelson
Ā 
Help Write A Research Paper - How To Write That Perfect
Help Write A Research Paper - How To Write That PerfectHelp Write A Research Paper - How To Write That Perfect
Help Write A Research Paper - How To Write That PerfectJeff Nelson
Ā 
Fundations Writing Paper G
Fundations Writing Paper GFundations Writing Paper G
Fundations Writing Paper GJeff Nelson
Ā 
Dreage Report News
Dreage Report NewsDreage Report News
Dreage Report NewsJeff Nelson
Ā 

More from Jeff Nelson (20)

Pin By Rhonda Genusa On Writing Process Teaching Writing, Writing
Pin By Rhonda Genusa On Writing Process Teaching Writing, WritingPin By Rhonda Genusa On Writing Process Teaching Writing, Writing
Pin By Rhonda Genusa On Writing Process Teaching Writing, Writing
Ā 
Admission Essay Columbia Suppl
Admission Essay Columbia SupplAdmission Essay Columbia Suppl
Admission Essay Columbia Suppl
Ā 
001 Contractions In College Essays
001 Contractions In College Essays001 Contractions In College Essays
001 Contractions In College Essays
Ā 
016 Essay Example College Level Essays Argumentativ
016 Essay Example College Level Essays Argumentativ016 Essay Example College Level Essays Argumentativ
016 Essay Example College Level Essays Argumentativ
Ā 
Sample Dialogue Of An Interview
Sample Dialogue Of An InterviewSample Dialogue Of An Interview
Sample Dialogue Of An Interview
Ā 
Part 4 Writing Teaching Writing, Writing Process, W
Part 4 Writing Teaching Writing, Writing Process, WPart 4 Writing Teaching Writing, Writing Process, W
Part 4 Writing Teaching Writing, Writing Process, W
Ā 
Where To Find Best Essay Writers
Where To Find Best Essay WritersWhere To Find Best Essay Writers
Where To Find Best Essay Writers
Ā 
Pay Someone To Write A Paper Hire Experts At A Cheap Price Penessay
Pay Someone To Write A Paper Hire Experts At A Cheap Price PenessayPay Someone To Write A Paper Hire Experts At A Cheap Price Penessay
Pay Someone To Write A Paper Hire Experts At A Cheap Price Penessay
Ā 
How To Write A Argumentative Essay Sample
How To Write A Argumentative Essay SampleHow To Write A Argumentative Essay Sample
How To Write A Argumentative Essay Sample
Ā 
Buy Essay Buy Essay, Buy An Essay Or Buy Essays
Buy Essay Buy Essay, Buy An Essay Or Buy EssaysBuy Essay Buy Essay, Buy An Essay Or Buy Essays
Buy Essay Buy Essay, Buy An Essay Or Buy Essays
Ā 
Top Childhood Memory Essay
Top Childhood Memory EssayTop Childhood Memory Essay
Top Childhood Memory Essay
Ā 
Essay About Teacher Favorite Songs List
Essay About Teacher Favorite Songs ListEssay About Teacher Favorite Songs List
Essay About Teacher Favorite Songs List
Ā 
Free College Essay Sample
Free College Essay SampleFree College Essay Sample
Free College Essay Sample
Ā 
Creative Writing Worksheets For Grade
Creative Writing Worksheets For GradeCreative Writing Worksheets For Grade
Creative Writing Worksheets For Grade
Ā 
Kindergarden Writing Paper With Lines 120 Blank Hand
Kindergarden Writing Paper With Lines 120 Blank HandKindergarden Writing Paper With Lines 120 Blank Hand
Kindergarden Writing Paper With Lines 120 Blank Hand
Ā 
Essay Writing Rubric Paragraph Writing
Essay Writing Rubric Paragraph WritingEssay Writing Rubric Paragraph Writing
Essay Writing Rubric Paragraph Writing
Ā 
Improve Essay Writing Skills E
Improve Essay Writing Skills EImprove Essay Writing Skills E
Improve Essay Writing Skills E
Ā 
Help Write A Research Paper - How To Write That Perfect
Help Write A Research Paper - How To Write That PerfectHelp Write A Research Paper - How To Write That Perfect
Help Write A Research Paper - How To Write That Perfect
Ā 
Fundations Writing Paper G
Fundations Writing Paper GFundations Writing Paper G
Fundations Writing Paper G
Ā 
Dreage Report News
Dreage Report NewsDreage Report News
Dreage Report News
Ā 

Recently uploaded

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
Ā 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
Ā 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
Ā 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
Ā 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docxPoojaSen20
Ā 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsKarinaGenton
Ā 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
Ā 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
Ā 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
Ā 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
Ā 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Celine George
Ā 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
Ā 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
Ā 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppCeline George
Ā 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptxVS Mahajan Coaching Centre
Ā 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
Ā 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
Ā 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
Ā 

Recently uploaded (20)

CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
Ā 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
Ā 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
Ā 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
Ā 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
Ā 
MENTAL STATUS EXAMINATION format.docx
MENTAL     STATUS EXAMINATION format.docxMENTAL     STATUS EXAMINATION format.docx
MENTAL STATUS EXAMINATION format.docx
Ā 
Science 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its CharacteristicsScience 7 - LAND and SEA BREEZE and its Characteristics
Science 7 - LAND and SEA BREEZE and its Characteristics
Ā 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Ā 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
Ā 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
Ā 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Ā 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
Ā 
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Incoming and Outgoing Shipments in 1 STEP Using Odoo 17
Ā 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
Ā 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
Ā 
URLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website AppURLs and Routing in the Odoo 17 Website App
URLs and Routing in the Odoo 17 Website App
Ā 
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions  for the students and aspirants of Chemistry12th.pptxOrganic Name Reactions  for the students and aspirants of Chemistry12th.pptx
Organic Name Reactions for the students and aspirants of Chemistry12th.pptx
Ā 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
Ā 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
Ā 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Ā 

Algoritma Dan Flowchart HOW DO WE SOLVE PROBLEMS

  • 1. 04/10/2014 1 Algoritma dan Flowchart Angga Akbar Fanani 1 Problem ā€¢ Pertanyaan atau tugas yang kita cari jawaban dan/atau penyelesaiannya 2 We "just do" Guesswork- and-luck Experience (possibly someoneelse's) Trial-and-error Scientifically" HOW DO WE SOLVE PROBLEMS?
  • 2. 04/10/2014 2 The Problem-solving Process 3 Problemspecification Algorithm Program Executable (solution) Design Implementation Compilation Analysis The Problem-solving Process Problem specification Algorithm Program Executable (solution) Analysis Design Implementation Compilation ā€œDoctor, my head hurtsā€œ Patient has elevated pressure in anterior parietal lobe 1. Sterilize cranial saw 2. Anaesthetize patient 3. Remove top of skull 4. Get the big spoon... 5. etc., etc. sterilize(saw,alcohol); raise_hammer(); lower hammer(fast); start(saw); /* etc. etc. */ 0100111010110010101010101001010101010100 11001010101010100101101001110101010101 00100101110100111101010101111101010100 0110100001101... 4
  • 3. 04/10/2014 3 5 Definisi Algoritma ā€¢ Algoritma adalah urutan langkah logis tertentu untuk memecahkan suatu masalah ā–« Urutan langkah logis, yang berarti algoritma harus mengikuti suatu urutan tertentu, tidak boleh melompat-lompat ā€¢ Alur pemikiran dalam menyelesaikan suatu pekerjaan yang dituangkan secara tertulis. ā–« Alur pikiran, sehingga algoritma seseorang dapat juga berbeda dari algoritma orang lain ā–« Tertulis, yang artinya dapat berupa kalimat, gambar, atau tabel tertentu 6
  • 4. 04/10/2014 4 Definisi Algoritma ā€¢ Deretan langkah-langkah komputasi yang mentransformasikan data masukan menjadi keluaran ā€¢ Deretan instruksi yang jelas untuk memecahkan masalah, yaitu untuk memperoleh keluaran yang diinginkan dari suatu masukan dalam jumlah waktu yang terbatas ā€¢ Prosedur komputasi yang terdefinisi dengan baik yang menggunakan beberapa nilai sebagai masukan dan menghasilkan beberapa nilai yang disebut keluaran. 7 Sejarah Algoritma ā€¢ Asal kata algoritma berasal dari nama Abu Jaā€™far Mohammed Ibn Musa al-Khowarizmi ā–« Ilmuan Persia yang menulis kitab al jabar wal- muqabala (the book of restoration and reduction) ā–« Tahun 825 M ā€¢ Perubahan kata ā–« Algorism ļƒ  proses menghitung dengan angka Arab ā–« Algorist ļƒ  orang yang menggunakan angka Arab ā–« Algorithm ļƒ  metode perhitungan secara umum ā€¢ Tahun 1950 ļƒ  euclidā€™s algorithm ā–« Langkah-langkah menemukan pembagi bersama terbesar (common greatest divisor = gcd) 8
  • 5. 04/10/2014 5 Ciri Algoritma (Donald E. Knuth) ā€¢ Finiteness: Algoritma harus berhenti setelah mengerjakan sejumlah langkah terbatas ā€¢ Definiteness: Setiap langkah harus didefinisikan secara tepat dan tidak berarti-dua (ambiguous) ā€¢ Algoritma memiliki nol atau lebih masukan (input) ā€¢ Algoritma memiliki nol atau lebih keluaran (output) ā€¢ Effectiveness: Algoritma harus efektif, setiap langkah harus sederhana sehingga dapat dikerjakan dalam sejumlah waktu yang masuk akal 9 Algorithm -- Examples ā€¢ A cooking recipe ā€¢ Assembly instructions for a model ā€¢ The rules of how to play a game ā€¢ VCR instructions ā€¢ Description of a martial arts technique ā€¢ Directions for driving from A to B ā€¢ A knitting pattern ā€¢ A car repair manual 10
  • 6. 04/10/2014 6 Almond and Honey Slice 1/2 quantity Shortcrust Pastry 185 g unsalted butter 100 g castor sugar 5 tablespoonshoney 50 ml cream 50 ml brandy or any other liqueuror spirit 300 g flaked almonds Preheat oven for 200Ā° C Line a 30 cm ļ‚“ 20 cm baking tray with baking paper, and then with pastry Bake blind for 20 minutes, then remove weights and foil Turn oven up to 220Ā° C. Bring remaining ingredients to a boil, stirring. Spread evenly over pastry. Bake until topping is bubblingand has caramelised evenly, about 15 minutes. Cool before cuttinginto fingers or squares. 11 From:Stephanie Alexander, The Cookā€™s Companion, Viking/Penguin, Ringwood, Victoria,1996, p. 349. Almond and Honey Slice 1/2 quantity Shortcrust Pastry 185 g unsalted butter 100 g castor sugar 5 tablespoonshoney 50 ml cream 50 ml brandy or any other liqueuror spirit 300 g flaked almonds Preheat oven for 200Ā° C Line a 30 cm ļ‚“ 20 cm baking tray with baking paper, and then with pastry Bake blind for 20 minutes, then remove weights and foil Turn oven up to 220Ā° C. Bring remaining ingredients to a boil, stirring. Spread evenly over pastry. Bake until topping is bubblingand has caramelised evenly, about 15 minutes. Cool before cuttinginto fingers or squares. 12 From:Stephanie Alexander, The Cookā€™s Companion, Viking/Penguin, Ringwood, Victoria,1996, p. 349. Instructions are given in the order in which they are performed (ā€œexecutedā€)
  • 7. 04/10/2014 7 Correct Algorithm? Cut chicken into pieces and brown the pieces on all sides in a casserole dish in hot olive oil. Remove the chicken and to the juices in the casserole add garlic, onions and green peppers, and sautĆ© until onion is golden. Add bay leaf, whole tomatoes, and chicken broth. When the broth boils add salt, saffron and rice. Arrange chicken on rice, cover casserole and bake in a moderate oven (350Ā°F) for 20 minutesor until the rice is tender. Add beans and artichokes during last 10 minutesof cooking. 13 From: ā€œArroz Con Polloā€ in The Margaret Fulton Cookbook, Hamlyn, Sydney, 1968. Correct Algorithm? Cut chicken into pieces and brown the pieces on all sides in a casserole dish in hot olive oil. Remove the chicken and to the juices in the casserole add garlic, onions and green peppers, and sautĆ© until onion is golden. Add bay leaf, whole tomatoes, and chicken broth. When the broth boils add salt, saffron and rice. Arrange chicken on rice, cover casserole and bake in a moderate oven (350Ā°F) for 20 minutesor until the rice is tender. Add beans and artichokes during last 10 minutesof cooking. 14 From: ā€œArroz Con Polloā€ in The Margaret Fulton Cookbook, Hamlyn, Sydney, 1968.
  • 8. 04/10/2014 8 Correct Algorithm? Cut chicken into pieces and brown the pieces on all sides in a casserole dish in hot olive oil. Remove the chicken and to the juices in the casserole add garlic, onions and green peppers, and sautĆ© until onion is golden. Add bay leaf, whole tomatoes, and chicken broth. When the broth boils add salt, saffron and rice. Arrange chicken on rice, cover casserole and bake in a moderate oven (350Ā°F) for 10 minutes. Add beans and artichokes. Cover, and bake for another 10 minutesor until rice is tender. 15 Correct algorithm ???... 16
  • 9. 04/10/2014 9 Correct algorithm 17 Values ā€¢ Represent quantities, amounts or measurements ā€¢ May be numerical or alphabetical (or other things) ā€¢ Often have a unit related to their purpose ā€¢ Example: ā–« Recipe ingredients 18
  • 10. 04/10/2014 10 Variables ā€¢ Are containers for values ā€“ places to store values ā€¢ Example: 19 This jar can contain 10 cookies 50 grams of sugar 3 slices of cake etc. Values Variable Restrictions on Variables ā€¢ Variables may be restricted to contain a specific type of value 20
  • 11. 04/10/2014 11 Instructions (Primitives) ā€¢ Some action that is ā–« simple ā–« unambiguous ā–« that the system knows about... ā–« ...and should be able to actually do 21 Instructions ā€“ Examples ā€¢ Take off your shoes ā€¢ Count to 10 ā€¢ Cut along dotted line ā€¢ Knit 1 ā€¢ Purl 2 ā€¢ Pull rip-cord firmly ā€¢ Sift 10 grams of arsenic 22 Directions to perform specific actions on values and variables
  • 12. 04/10/2014 12 Instructions -- Application ā€¢ Some instructions can only be applied to a specific type of values or variables ā€¢ Examples: 23 Instructions (Primitives) -- Recommendations ā€¢ When writing an algorithm, make each instruction simple and unambiguous ā€¢ Example: 24 Cut chicken into pieces and brown the pieces on all sides in a casserole dish in hot olive oil. Cut chicken into pieces. Heat olive oil in a casserole dish. Brown the chicken pieces in the casserole dish.
  • 13. 04/10/2014 13 Instructions (Primitives) ā€¢ When writing an algorithm, make each instruction simple and unambiguous ā€¢ Example: 25 Cut chicken into pieces and brown the pieces on all sides in a casserole dish in hot olive oil. Cut chicken into pieces. Heat olive oil in a casserole dish. Brown the chicken pieces in the casserole dish. A ā€œsequenceā€ of simple instructions Function ā€¢ A named sequence of instructions ā€¢ So that you can ā–« Refer to it collectively (by name) ā–« ...instead of individually (by each instruction in the sequence) ā€¢ Example: ā–« Drive_To_Uni 26
  • 14. 04/10/2014 14 Function -- Example function Drive_To_Uni { 1. find car keys 2. disable car alarm 3. open car door 4. get in car 5. shut car door 6. put keys in ignition 7. start car 8. back car out of driveway 9. drive to end of street 10. turn right 11. drive to end of street 12. turn left ...etc...etc...etc 27 ...etc...etc...etc... 52. find parking space 53. pull into parking space 54. turn off engine 55. remove keys from ignition 56. open car door 57. get out 58. shut car door 59. lock car door 60. enable alarm } Function ā€“ Example function Do_Wednesday { Wake_up Have_Shower Eat_Breakfast Drive_To_Uni Sit_1301_Lecture ...etc...etc...etc... Drive_From_Uni ...etc...etc...etc... } function Do_Week { Do_Monday Do_Tuesday Do_Wednesday Do_Thursday ...etc...etc...etc... } 28
  • 15. 04/10/2014 15 Components of an Algorithm ā€¢ Variables and values ā€¢ Instructions ā–« Sequences ā–« Functions ā–« Selections ā–« Repetitions Also required: Documentation 29 Struktur dasar algoritma Struktur Urut (Sequence), Struktur Pemilihan (Selection), Struktur Pengulangan (Repetition). 30
  • 16. 04/10/2014 16 Sequence ā€¢ A series of instructions ā€¢ ...to be carried out one after the other... ā€¢ ...without hesitation or question ā€¢ Example: ā–«How to cook a Gourmet MealTM 31 Sequence -- Example 1. Open freezer door 2. Take out Gourmet Mealā„¢ 3. Close freezer door 4. Open microwave door 5. Put Gourmet Mealā„¢ on carousel 6. Shut microwave door 7. Set microwave on high for 5 minutes 8. Start microwave 9. Wait 5 minutes 10.Open microwave door 11.Remove Gourmet Mealā„¢ 12.Close microwave door 32
  • 17. 04/10/2014 17 Struktur Urut (Sequence) ā€¢ suatu strukturprogram dimana setiap baris program akan dikerjakan secara urut dari atas ke bawah sesuai dengan urutan penulisannya. ā€¢ instruksibaris program 2 akan dikerjakan jika instruksi baris program 1 telah selesai dikerjakan. 33 Selection ā€¢ An instruction that decides which of two possible sequences is executed ā€¢ The decision is based on a single true/false condition ā€¢ Examples: ā–« Car repair ā–« Reciprocals 34
  • 18. 04/10/2014 18 Selection Example ā€“ Car Repair if (motor turns) then { CheckFuel CheckSparkPlugs CheckCarburettor } else { CheckDistributor CheckIgnitionCoil } 35 Selection Example ā€“ Car Repair if (motor turns) then { CheckFuel CheckSparkPlugs CheckCarburettor } else { CheckDistributor CheckIgnitionCoil } 36 Should be a true or false condition
  • 19. 04/10/2014 19 Selection Example ā€“ Car Repair if (motor turns) then { CheckFuel CheckSparkPlugs CheckCarburettor } else { CheckDistributor CheckIgnitionCoil } 37 Sequence if the condition is true Selection Example ā€“ Car Repair if (motor turns) then { CheckFuel CheckSparkPlugs CheckCarburettor } else { CheckDistributor CheckIgnitionCoil } 38 Sequence if the condition is false
  • 20. 04/10/2014 20 Struktur Pemilihan (Selection), ā€¢ Menghasilkan nilai benar (true) atau nilai salah (false). ā€¢ IF sederhana ļ‚– IF <syarat> THEN <instruksi> ā€¢ Pada bentuk IF sederhana ini, intruksi akan dikerjakan jika syarat yangdiuji benilai benar (true). Jika syarat yang diuji benilai salah (false) maka tidak ada instruksi yang dikerjakan. 39 IF ā€¦ THEN ā€¦ ELSE ā€¦ ā€¢ IF <syarat> THEN <instruksi1> ELSE <instruksi2> ā€¢ Pada bentuk ini terdapat dua kemungkinan pilihan yang akan dikerjakan berdasarkan hasil pengujian, jika syarat yang diuji benilai benar maka instruksi1 yang dikerjakan, dan jika syarat yang diuji bernilai salah maka instruksi2 yang dikerjakan. 40
  • 21. 04/10/2014 21 IF Bersarang (Nested IF) ā€¢ IF <syarat1> THEN <instruksi1> ā€¢ ELSE IF <syarat2> THEN <instruksi2> ā€¢ ELSE IF <syarat3> THEN <instruksi3> ā€¢ ELSE IF <syaratm> THEN <instruksim> ā€¢ ELSE <Instruksin> 41 Repetition ā€¢ Repeat an instruction... ā–« ...while (or maybe until) some true or false condition occurs ā–« Test the condition each time before repeating the instruction ā€¢ Also known as iteration or loop ā€¢ Example: ā–« Algorithm for getting a date 42
  • 22. 04/10/2014 22 Repetition ā€“ Example function AskOnDate ( name, time, location ) { Phone(name) Say("Hey", name, "it's your lucky day!") Say("Wanna come to", location, "at", time, "?") ListenToReply ( ) start begging count at zero while (reply is "No" and begging count < 100) { Say("Oh please!") add 1 to begging count ListenToReply ( ) } } 43 Repetition ā€“ Example (cont) function AskOnDate ( name, time, location ) { Phone(name) Say("Hey", name, "it's your lucky day!") Say("Wanna come to", location, "at", time, "?") ListenToReply ( ) start begging count at zero while ( reply is "No" and begging count < 100 ) { Say("Oh please!") add 1 to begging count ListenToReply ( ) } } 44 Condition is tested before sequence
  • 23. 04/10/2014 23 Repetition ā€“ Example (cont) function AskOnDate ( name, time, location ) { Phone(name) Say("Hey", name, "it's your lucky day!") Say("Wanna come to", location, "at", time, "?") ListenToReply ( ) start begging count at zero while (reply is "No" and begging count < 100) { Say("Oh please!") add 1 to begging count ListenToReply ( ) } } 45 Sequence may not get executed at all Repetition ā€“ Example (cont) function AskOnDate ( name, time, location ) { Phone(name) Say("Hey", name, "it's your lucky day!") Say("Wanna come to", location, "at", time, "?") ListenToReply ( ) start begging count at zero while (reply is "No" and begging count < 100) { Say("Oh please!") add 1 to begging count ListenToReply ( ) } } 46 Ensure initial values of variables used in the conditions are set correctly
  • 24. 04/10/2014 24 Repetition ā€“ Example (cont) function AskOnDate ( name, time, location ) { Phone(name) Say("Hey", name, "it's your lucky day!") Say("Wanna come to", location, "at", time, "?") ListenToReply ( ) start begging count at zero while (reply is "No" and begging count < 100) { Say("Oh please!") add 1 to begging count ListenToReply ( ) } } 47 Ensure the variables used in the conditions are updated in each repetition Repetition ā€“ Example (cont) function AskOnDate ( name, time, location ) { Phone(name) Say("Hey", name, "it's your lucky day!") Say("Wanna come to", location, "at", time, "?") ListenToReply ( ) start begging count at zero while (reply is "No" and begging count < 100) { Say("Oh please!") } } 48 Infinite loop ā€¢ What if we donā€™t increment the begging count?
  • 25. 04/10/2014 25 Struktur pengulangan repetition ā€¢ Struktur for ā€¢ Mengulangsatu baris instruksiatau satu blok instruksisampai jumlah perulanganyang disyaratkanterpenuhi. ā€¢ Ciri utama terdapatnilai awaldan nilai akhir yang menunjukkanbanyaknya pengulanganyang akan dilakukan. 49 Struktur while ā€¢ untukmengulangsatu baris instruksi atau satu blok baris instruksi selama syarat yang diberikan masih terpenuhi. ā€¢ Syarat akan diuji didepan. ā€¢ Jika syarat yang diuji bernilai benar maka instruksi1,instruksi2, instruksi3 akan dikerjakan, setelah mengerjakan instruksi1, instruksi2, instruksi3 maka syarat akan diuji lagi. ā€¢ pengulangan akan berhentijika syarat yang diuji bernilai salah. 50
  • 26. 04/10/2014 26 Struktur do ā€¦ while ā€¢ mengulangsatu baris instruksi atau satu blok baris instruksi sampai syarat tidak terpenuhi. ā€¢ syarat akan diuji dibelakang, sehinggabaris instruksi yang masukdalam blok doā€¦while minimal akan dikerjakan satu sekali. 51 Documentation ā€¢ Records what the algorithm does ā€¢ Describes how it does it ā€¢ Explains the purpose of each component of the algorithm ā€¢ Notes restrictions or expectations ā€¢ Example: ā–« Getting a date (again) 52
  • 27. 04/10/2014 27 Documentation -- Example Think of something romantic to do decide on time and location Work through address book to look for a person initialise booking to ā€œunsuccessfulā€ until (successfully booked) { get next Name in little black book AskOnDate(Name, Time, Location) DetermineBookingSuccess } Assumes that I will find someone in the book before it runs out SighWithRelief 53 From Algorithms to Programs 54 Problem Program Program Algorithm Algorithm: A sequence of instructions describing how to do a task (or process)
  • 28. 04/10/2014 28 The Software Development Process ā€¢ Define the problem clearly ā€¢ Analyse the problem thoroughly ā€¢ Design an algorithm carefully ā€¢ Code the algorithm efficiently ā€¢ Test the code thoroughly ā€¢ Document the system lucidly 55 Top-down Algorithm Design ā€¢ Write down what you have to do ā€¢ Break that into 3-7 smaller steps ā€¢ Break each step into 3-7 smaller steps ā€¢ Keeping subdividing until each individual step is easy enough to do ā€¢ Example: ā–« Learning 56
  • 29. 04/10/2014 29 Top-down Design -- Example 57 Learn Prepare Study Reinforce Read Make notes Prepare questions Attend lecture Listen and think Complete prac Attend tute Record answers to questions Revise notes Read lecture notes Read textbook Read exercise Design algorithm Code solution Test and document Record insights Cara Penyajian Algoritma ā€¢ Uraian Deskriptif ā–« Menggunakan bahasa yang bisa di gunakan sehari- hari ā€¢ Menggunakan flow chart (diagram alir) ā€¢ Menggunakan pseudo-code ā–« Ditulis dalam kode-kode yang disepakati yang mempunyai arti 58
  • 30. 04/10/2014 30 59 Algoritma dan Flowchart ā€¢ Algoritma merupakan urutan langkah logika pemikiran detail yang diperlukan untuk memecahkan masalah. ā€¢ Algoritma dapat direpresentasikan dalam format grafis yang disebut flowchart atau diagram alir. ā€¢ Flowchart juga dapat digunakan untuk menggambarkan aliran urutan program 60
  • 31. 04/10/2014 31 Bagan-bagan Flowchart ā€¢ Terminal ā–« Bentuk : rounded rectangle ā–« Mengindikasikan titik awal atau akhir 61 Bagan-bagan Flowchart ā€¢ Connector ā–« Bentuk : circle ā–« Mengindikasikan titik penghubung ke bagan lain yang terputus dalam satu halaman karena terlalu jauh atau memungkinkan memotong garis panah lain 62
  • 32. 04/10/2014 32 Bagan-bagan Flowchart ā€¢ Connector ā–« Bentuk : pentagon ā–« Mengindikasikan titik penghubung ke bagan lain yang terputus karena beda halaman 63 Bagan-bagan Flowchart ā€¢ Preparation atau initialization ā–« Bentuk : hexagon ā–« Mengindikasikan tahap awal pemrograman (misalnya mendeklarasikan variabel, mengidentifikasikan nilai awal konstanta atau variabel) 64
  • 33. 04/10/2014 33 Bagan-bagan Flowchart ā€¢ Data ā–« Bentuk : parallelogram ā–« Mengindikasikan masukan atau keluaran data 65 Bagan-bagan Flowchart ā€¢ Process ā–« Bentuk : rectangle ā–« Mengindikasikan proses komputasi 66
  • 34. 04/10/2014 34 Bagan-bagan Flowchart ā€¢ Predefined/Nested Process (Subroutine) ā–« Bentuk : rectangle ā–« Mengindikasikan proses komputasi 67 Bagan-bagan Flowchart ā€¢ Manual Operation ā–« Bentuk : trapezoid ā–« Mengindikasikan operasi yang dilakukan secara manual 68
  • 35. 04/10/2014 35 Bagan-bagan Flowchart ā€¢ Manual Input ā–« Bentuk : trapezoid ā–« Mengindikasikan masukan manual menggunakan input device (misalnya keyboard, mouse, bar code reader, imaging device) 69 Bagan-bagan Flowchart ā€¢ Card ā–« Bentuk : chamfered rectangle ā–« Mengindikasikan penggunaan card reader (misalnya punched card reader ataupun memory card reader) 70
  • 36. 04/10/2014 36 Bagan-bagan Flowchart ā€¢ Database atau Repository ā–« Bentuk : drum ā–« Mengindikasikan penggunaan media penyimpanan basisdata 71 Bagan-bagan Flowchart ā€¢ Display ā–« Bentuk : CRT Symbol ā–« Mengindikasikan proses penampilan informasi untuk dibaca atau dilihat user di layar monitor atau projector 72
  • 37. 04/10/2014 37 Bagan-bagan Flowchart ā€¢ Report ā–« Bentuk : Sheet ā–« Mengindikasikan proses pencetakan laporan untuk dibaca atau dilihat user menggunakan printer atau plotter 73 Bagan-bagan Flowchart ā€¢ Annotation ā–« Bentuk : Arrow ā–« Mengindikasikan hubungan presedensi antar operasi atau alur urutan operasi 74
  • 38. 04/10/2014 38 Bagan-bagan Flowchart ā€¢ Decision ā–« Bentuk : diamond ā–« Mengindikasikan pencabangan alternatif operasi dengan pengambilan keputusan berdasarkan kriteria atau kondisi 75 Decision / Condition Structure 76 YES NO YES NO YES NO YES NO
  • 39. 04/10/2014 39 Repetition / Recursive Structure 77 YES NO YES NO Metodologi Pengembangan Program 78 Mulai Analisis Domain Masalah Merumuskan Algoritma Semua Skenario Tertulis ? Mapping Flowchart Struktur Logika Sesuai ? Verify Program Code Identifier, Syntax, Semantic ? Debug Listing Program Compile Machine Code Compile Berhasil ? Eksekusi Program Eksekusi Berhasil ? Keluaran Program Sesuai ? Eksekusi Program Selesai
  • 40. 04/10/2014 40 Contoh Algoritma ļ‚¢Step 1: Turn the stereo on. ļ‚¢Step 2: If the band is set to FM, switch it to AM. ļ‚¢Step 3: If the station is set to a station greater than 610, turn the station to the left until 610 is reached. ļ‚¢Step 4: If the station is set to a station less than 610, turn the station to the right until 610 is reached. ļ‚¢Step 5: Listen to the best sports talk station in the country. 79 80 Contoh Flowchart