Fazmah Arif Yulianto CS1013 Pengantar Teknik Informatika 20082 Lets get serious I Pen and Paper Bagaimana kita melakukan perkalian bilangan Hafalan ID: 793785
Download The PPT/PDF document "05 | 20090224 Algorithm & Efficien..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
05 | 20090224 Algorithm & Efficiency
Fazmah Arif Yulianto
CS1013 –
Pengantar
Teknik
Informatika
-
20082
Slide2Slide3Let’s get serious
Slide4I: Pen and PaperBagaimana kita melakukan
perkalian bilangan?Hafalan
Dengan
Bantuan
Tangan
Kertas
Kalkulator
Manakah
yang
merupakan
Algoritma
?
Slide5Menggunakan Angka Arab 2345 678 x 18760
16415 14070 + 1589910
Mengalikan menggunakan Kertas
Angka Romawi
MMCCCVL
DLXXVIII x
?
Slide6Ciri algoritma:
TerencanaDapat dilakukan
Selesai
Algorithm
Input
Computational steps
Output
Slide7Using natural languageUsing flowchart
Using pseudocodeUsing program source code
…
Specifying an algorithm
Slide8Correctness100%Approx alg
the error < limitEfficiency:Time & Space efficiency
Simplicity
Generality:
the problem
input range
Algorithm Qualities
Slide93 Komponen AlgoritmaParadigma IPOSetiap
Algoritma dapat disebutkan:Input : masukan
Proses
: me-
‘*^%$’
-
kan
I
O
Output :
keluaran
Slide10Latihan I: Pen and PaperPada Algoritma perkalian
menggunakan kertas, sebutkan IPOnya.
Input :
Dua
buah
bilangan
Proses
:
<pre-memory>
Output :
Bilangan hasil perkalian
Slide11II: Resep MasakanResep membuat Cap CayInput : Bahan Masakan, dan Cara MemrosesnyaProses : <interpretasi> <urutan>Output : Cap Cay untuk 6 orang
Slide12Morale IISingkat, ada
Asumsi, Kamus dan atau Knowledge BaseMemungkinkan
Paralel
Processing
Garnish,
Kuah
,
Utama
,
Isi
,
dsb Adanya Konsep ModularityBakso, Maizena, tinggal pake
’ ajaInput – Output - Movement
Slide13The Need of Efficient AlgorithmSuppose that you have an infinitely fast computer equipped with unlimited capacity of free-memory.
Do you still have any reason to study algorithm?
Slide14Absolutely YES!You still have to demonstrate that your solution method terminates and does so with the correct answer
Slide15Back to the real worldComputers may be fast, but they are not infinitely fastMemory may be cheap, but it is not free.
Bounded resources:Computing timeSpace in memory
Energy (mind your laptop battery) etc.
These resources must be used wisely, and efficient algorithms will help you do so
Slide16Performance: the amount of CPU / memory / disk usage / energy etc.Complexity: how well the algorithm scalesBig-Othe number of operations required to perform a function
expression representing some growth relative to the size of the problem (N)Exp: O(1), O(N), O(N2), O(log N), …
Efficiency
Slide17an algorithm takes constant time to run; performance isn’t affected by the size of the problemExp: addressing main memory in a computerarray lookup
O(1)
Slide18the number of operations required to perform a function is directly proportional to the number of items being processedExp: waiting in a line at a supermarketAssume: 2 mins
/ cust (avg)10 cust
20
mins
; 100
cust
200
mins
O(N)
Slide19Each member of the group greets every other memberO(N2)
6 persons
5+4+3+2+1 = 15
7 persons 21
8 persons 28
…
N persons (N
2
-N)/2 greets
Slide20Big O disregard any constant (N2-N)as N becomes larger, subtracting N from N2
will have less and less of an overall effectO(N2): (N
2
-N)/2
N
2
Slide21Fast algorithms often make use of very complicated data structures, or use other complicated algorithms as subroutinesChallenge: making more complicated algorithms worthy of consideration in practice
Implementation Complexity
Slide22The world without computer engineers
Slide23Kur
IF 2008
Slide24Let’s do some actions
Slide25Write your algorithm(s) to sort cards from the same suit:You can see all the cards & you can use your both handsCards are all placed face down on the table & you can only use one handWhat is your: average step-count?
Do you find special cases (worst & best)?Card Sorting
Slide26Try to put eight chess queens on an 8×8 chessboard such that none of them is able to capture any other using the standard chess queen's moves8-Queens Puzzle