Sie sind auf Seite 1von 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/

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)

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

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

Introduction

ALGORITHM AND DATA STRUCTURE

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 dont do anything by
themselves.

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

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
Symbols

Decision

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 3

statement block 2

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
else
statement block 2
end if

True

False

condition
statement
block 1

statement
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
block

True

condition
False

17

Contoh#1
Tuliskan Pseudecode
dan algoritma serta
gambarkan
flowchartnya untuk
menghitung konversi
derajat Fahrenheit ke
Celcius.

Pseudocode:
Input derajat Fahrenheit
Hitung derajat Celcius
Print derajat Celcius

18

Contoh#1
Pseudocode:
Input derajat
Fahrenheit
Hitung derajat Celcius
Print derajat Celcius

Algoritma
(Deskripsi/rincian langkah)
Input F
C (F - 32.0) * 5.0 /9.0
Print C

19

Contoh#1
Flowchart

Algoritma
(Deskripsi/rincian
langkah)
Input F
C (F - 32.0) * 5.0 /9.0
Print C

START

Input F

C (F - 32.0) * 5.0 /9.0

Print C

STOP

20

Contoh#2
Tuliskan Pseudecode
dan algoritma serta
gambarkan
flowchartnya untuk
menentukan nilai
tertinggi dari dua nilai
yang diinput dan
kemudian mencetak
nilai tertinggi tersebut.

Pseudocode:
Input nilai A dan B
Tentukan nilai tertinggi
dengan
membandingkan nilai A
dan B
Print nilai tertinggi

21

Contoh#2
Pseudocode:
Input nilai A dan B
Tentukan nilai tertinggi
dengan
membandingkan nilai A
dan B
Print nilai tertinggi

Algoritma
(Deskripsi/rincian langkah)
Input A,B
if (A > B ) then
NT A
else
NT B
endif
Print NT

22

Contoh#2
START

Algoritma
(Deskripsi/rincian
langkah)

Input A,B

Input A,B
if (A > B then )
NT A
else
NT B
endif
Print NT

Flowchart

Apakah
A>B
?

NT A

NT B

Print
Nilai Tertinggi adalah, NT

STOP

23

Das könnte Ihnen auch gefallen