You are on page 1of 23

Algoritma dan Struktur Data

Kuliah #1
By
Dr. Amil Ahmad Ilham, S.T., M.IT.
http://www.unhas.ac.id/amil
Materi Kuliah
• Slides dapat di download di:
http://www.unhas.ac.id/amil/mk/S1TE/2014_2/AS/

2
Rules!
• Please be aware that:
– No mark (zero) for late assignments without prior
permission or urgent reasons.
– No mark (zero) for cheated assignments or exams.
– No talks via mobile phone during class.
• Silent mode is OK
• You can leave class if you have an urgent call.
– No FB, Twitter, SMS, etc, during class.
– No “kaos oblong” and “sandal”.
– No smoking!
– Snack/candy is OK during class.

3
Penilaian
• Mid/Final Test (wajib diikuti)
– Total Nilai = 0, jika Mid/Final Test tidak diikuti.
• Quiz (kapan saja)
• Tugas (Individu/Kelompok)

4
Perbaikan Nilai
• Tidak ada (waktu) perbaikan nilai.
• Ujian susulan hanya akan diberikan jika
berhalangan hadir pada saat ujian karena:
– Sakit atau alasan pribadi lain yang dapat diterima.
– Ada pemberitahuan pada saat ujian atau sebelum
ujian

5
Contact info
• HP: 0853-9883-1853 (SMS and URGENT CALL
ONLY)
• amil_ai@yahoo.com

6
Introduction

ALGORITHM AND DATA STRUCTURE

7
What is a computer
• Computer
– is a device that receives input,
stores and processes data, and
provides output in a useful format.
• Computers are NOT intelligent
or telepathic
– Computers do what we tell them to
do they don’t do anything by
themselves.

8
Need for Programming
• Computers are just electronic devices that
have the power to perform difficult tasks but
they do not ‘KNOW’ what to do.
• Programmers tell the computers what to do
by writing programs

9
What is a Computer Program?
• A computer program is
– a set of instructions written in a computer language
– executed to perform a specific task.
– Also called SOFTWARE

10
What is an Algorithm?
• The plan for writing a program.
• The sequence of steps that describe solution of
problem.
• Algorithms are written according to rules so that
other programmers are also able to read and
understand the solution easily.

11
Flowcharts
• Flowcharts are graphical tools, containing a set of
shapes, each expressing a different action in a
sequence of program execution.
• A Flowchart
– shows logic of an algorithm
– emphasizes individual steps and their
interconnections
– e.g. control flow from one action to the next

12
Pseudocode
• Pseudocode is an artificial and informal
language that helps programmers develop
algorithms. Pseudocode is very similar to
everyday English (Indonesian)
– Biasanya dibuat sebelum menulis algoritma atau
menggambar flowchart.

13
Start or stop

Process

Input

Flowchart Decision

Symbols Flow line

Connector

Output

Off-page connector
14
Sequences
A sequence of instructions that are executed in
the precise order they are written in:

statement block 1
statement block 1
statement block 2 statement block 2

statement block 3
statement block 3

15
Conditionals
Select between alternate courses of action
depending upon the evaluation of a condition

If ( condition = true ) then


statement block 1 True False

else condition
statement block 2
end if statement statement
block 1 block 2

16
Loops
Loop through a set of statements as long as a
condition is true

Loop while ( condition = true )


statement block
end Loop

statement True
condition
block
False

17
Contoh#1
• Tuliskan Pseudecode Pseudocode:
dan algoritma serta • Input derajat Fahrenheit
gambarkan • Hitung derajat Celcius
flowchartnya untuk • Print derajat Celcius
menghitung konversi
derajat Fahrenheit ke
Celcius.

18
Contoh#1
Pseudocode: • Algoritma
• Input derajat (Deskripsi/rincian langkah)
Fahrenheit
• Hitung derajat Celcius Input F
C ← (F - 32.0) * 5.0 /9.0
• Print derajat Celcius Print C

19
Contoh#1
Flowchart
• Algoritma START
(Deskripsi/rincian
langkah) Input F

Input F
C ← (F - 32.0) * 5.0 /9.0 C ← (F - 32.0) * 5.0 /9.0
Print C

Print C

STOP

20
Contoh#2
• Tuliskan Pseudecode Pseudocode:
dan algoritma serta • Input nilai A dan B
gambarkan • Tentukan nilai tertinggi
flowchartnya untuk dengan
menentukan nilai membandingkan nilai A
tertinggi dari dua nilai dan B
yang diinput dan • Print nilai tertinggi
kemudian mencetak
nilai tertinggi tersebut.

21
Contoh#2
Pseudocode: • Algoritma
• Input nilai A dan B (Deskripsi/rincian langkah)
• Tentukan nilai tertinggi Input A,B
dengan
membandingkan nilai A if (A > B ) then
dan B NT ← A
else
• Print nilai tertinggi NT ← B
endif

Print NT

22
Contoh#2 Flowchart
START
• Algoritma
(Deskripsi/rincian
Input A,B
langkah)
Input A,B
Y N
Apakah
A>B
if (A > B then ) ?
NT ← A
else NT ← A NT ← B
NT ← B
endif
Print
Print NT “Nilai Tertinggi adalah”, NT

STOP 23

You might also like