Kompleksitas - WordPress.com

Kompleksitas 1
Kompleksitas log n
Proc tambah (x,y:int)
C=int
C=x+y
Proc kurang (x,y:int)
C=int
C=x-y
Proc kali (x,y:int)
C=int
C=x*y
Proc bagi (x,y:int)
C=int
If (y=0) then
Output (“error”)
Else
C=x/y
Func bool (x:int)
Re:false
If(x<=0) then
Return Re
Else
Re=true
Return Re
Kompleksitas n log n
Kompleksitas n
Kompleksitas n2
Procedure cetak_array_2_dimensi(array[ ][ ] : integer
,maxB : integer, maxK :integer)
i : integer
j : integer
For ( i = 1 to maxK) do
For ( j = 1 to maxB )
Print(array[ i ][ j ])
end for
end for
Procedure input_array_2_dimensi(array[ ][ ] : integer
,maxB : integer, maxK :integer)
i : integer
j : integer
For ( i = 1 to maxK) do
For ( j = 1 to maxB )
input(array[ i ][ j ])
end for
end for
Procedure cari_array_2_dimensi(array[ ][ ] : integer ,maxB
: integer, maxK :integer, x : integer)
Algorithm ClosestPairPoints (P)
dmin ← ∞
i : integer
for i ← 1 to n-1 do
j : integer
for j ← i + 1 to n do
For ( i = 1 to maxK) do
d ← sqrt ((xi – xj) 2 + (yi – yj)2)
For ( j = 1 to maxB )
if d < dmin
If (array[i][j] == x )
dmin ← d
Output (“Data ketemu pada array ”,I,”
”,j)
end if
end for
end for
Kompleksitas 2n
Algorithm SelectionSort (A[0..n-1])
for i ← 0 to n-2 do
Kompleksitas n!
Algoritma TSP (Travel Salesman Problem)
min ← i
for j ← i + 1 to n-1 do
if A[j] < A[min]
min ← j
swap A[i] and A[min]
Algorithm BubbleSort (A[0..n-1])
for i ← 0 to n-2 do
for j ← 0 to n – 2 – i do
if A[j+1] < A[j]
swap A[j] and A[j+1]
Sumber
https://en.wikipedia.org/wiki/Binary_search_algorithm
http://www.codingeek.com/algorithms/linear-searchalgorithm-and-its-implementation-example/
http://bertzzie.com/knowledge/analisisalgoritma/KompleksitasAlgoritma.html#o-n-kompleksitaslinear
http://faculty.simpson.edu/lydia.sinapova/www/cmsc250/
LN250_Levitin/L05-BruteForce.htm
file:///D:/telkom/20130916_11KompleksitasAlgoritma.pdf
https://en.wikipedia.org/wiki/Brute-force_search