CLOSEST
PAIR
PROBLEM
Permasalahan
closest pair adalah cara yang digunakan ketika ingin mencari dua
titik yang berdekatan pada n titik.
Permasalahan
closest pair pada kehidupan sehari-hari :
ATC
: mencari jarak terdekat antar 2 pesawat atau lebih yang memiliki
kemungkinan bertabrakan.
CONTOH
KASUS
CLOSEST PAIR
ALGORITHM BruteForceClosestPair(P )
//Finds distance between two closest points in the plane by brute force
//Input: A list P of n(n≥ 2) points ,...,
//Output: The distance between the closest pair of points
d ←∞
for i ← 1 to n − 1 do
for j ← i + 1 to n do
d ← min(d, sqrt((− +(− ) //sqrt is square root
return d
ALGORITHM BruteForceClosestPair(P )
//Finds distance between two closest points in the plane by brute force
//Input: A list P of n(n≥ 2) points ,...,
//Output: The distance between the closest pair of points
d ←∞
for i ← 1 to n − 1 do
for j ← i + 1 to n do
d ← min(d, sqrt((− +(− ) //sqrt is square root
return d
0 komentar:
Posting Komentar