# Introduction to The Design & Analysis of Algorithms

## Presentasi berjudul: "Introduction to The Design & Analysis of Algorithms"— Transcript presentasi:

Introduction to The Design & Analysis of Algorithms
By INDRIATI Teknik Informatika - UB

See page 2; quoted: “..…. a person does not really understand something until after teaching it to someone else ……” actually: “ a person does not REALLY understand something until after teaching it to a computer.”

An algorithm is a sequence of unambiguous instructions
for solving a problem, i.e. for obtaining a required output for any legitimate input in a finite amount of time.

What is algorithm? An algorithm is a sequence of computational steps that transform the input into the output An algorithm is a tool for solving a well-specified computational problem

Algorithm is.... Algoritma adalah cara yang dapat ditempuh oleh komputer dalam mencapai suatu tujuan, terdiri atas langkah-langkah yang terdefinisi dengan baik, menerima input, melakukan proses, dan menghasilkan output. Meskipun tidak selalu, biasanya sebuah algoritma memiliki sifat bisa dihitung (computable) atau bisa diukur (measurable).

An algorithm is written in pseudocode,
i.e. a mixture of a natural language and programming language-like construct if – then if – then – else for – do while – do repeat – until

if – then if – then – else C C false true false true S S1 S2
next statement next statement if – then if – then – else

for k  1 to n do . done n times

while – do false C true S next statement

repeat – until S C false true next statement

STEPS 1. understand the problem
2.      ascertain the capabilities of the computational device 3.      choose between exact and approximate problem solving 4.      decide on appropriate data structures 5.      determine algorithm design techniques 6.      select the method of specifying an algorithm 7.      prove the algorithm’s correctness 8.      analyze the algorithm 9.      code the algorithm

the most important problem types are:
1. sorting rearrange items of a given list in a specific order, based on some key 2. searching find a given search key in a given set 3. string processing search a word in a text next…

5. combinatorial problems
4. graph problems includes graph traversal problems, shortest-path algorithms, topological sorting, graph coloring problems 5. combinatorial problems e.g. traveling salesman next…

6. geometric problems 7. numerical problems
the closest-pair problem, the convex hull problem 7. numerical problems solve equations & systems of equations, evaluate functions, etc.

PSEUDOCODE (1) Algorithm to display seven symbols of #
1 for i <- 1 to 7 do 2 display ”#” 3 end for

PSEUDOCODE (2) Algorithm to calculate Faktorial from N 1 iTemp <- 1
2 for i <- 1 to N do 3 iTemp <- iTemp*i 4 end for 5 display ”Factorial from ”,N,” is ”,iTemp [buku utama, pseudocode 2.8b]

PSEUDOCODE (3) Algorithm to display 8 Fibonacci number 1 f1 <- 0
3 for i <-1 to 8 do 4 iFibo <- f1+f2 5 display ”Number ”,i,” is ”,iFibo 6 f1 <-f2 7 f2<- iFibo 8 end for

LATIHAN Buatlah sebuah pseudocode untuk menampilkan N bilangan pertama secara terbalik. contoh : 10, 9, 8, 7, 6, 5, 4, 3, 2, 1 Buat dengan menggunakan teknik for-do! Buat dengan menggunakan teknik repeat-until! Buat dengan menggunakan teknik while-do!

LATIHAN Buat sebuah pseudocode yang akan menerima sebuah bilangan X dari user. Tampilkan pesan “benar” jika X habis dibagi 2, 3 atau 7 dan tampilkan “salah” jika tidak habis dibagi.

Assignment Algorithm Efficiency Description Parameters
Types and description Deadline: Sept 22, 2010 to : Subject : Algorithm Effieciency [NIM]

Presentasi serupa