Advanced Algorithms Analysis and Design - CS702 Power Point Slides Lecture 13
Advanced Algorithms Analysis and Design - CS702 Power Point Slides Lecture 13
Design
By
1. d(x, y) ≥ 0,
2. d(x, y) = 0 if and only if x = y.
3. Symmetric i.e.
d(x, y) = d(y, x).
4. Triangle inequality:
d(x, z) ≤ d(x, y) + d(y, z).
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
Finding Closest Pair in 2-D
Closest Pair Problem in 2-D
• A point in 2-D is an ordered pair of values (x, y).
• The Euclidean distance between two points
Pi = (xi, yi) and Pj = (xj, yj) is
d(pi, pj) = sqr((xi − xj)2 + (yi − yj)2)
• The closest-pair problem is finding the two closest
points in a set of n points.
• The brute force algorithm checks every pair of points.
• Assumption: We can avoid computing square roots by
using squared distance.
– This assumption will not loose correctness of the problem.
9. mini i
10.minj j ( n ) 2
(n 1)n
7. if d < mind then cn(n 1) c
2
8. mind d 2
9. mini i
n n
c(n n )
2
10.minj j 2 2
n2 n
11.return mind, p(mini, minj) c ( ) ( n 2 )
2 2
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
The Closest Pair Problem 3-D
10.minj j ( n 2 )
11.return mind, p(mini), p(minj)
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
The Closest Pair Problem n-D
1 2 3 4 5 6 7 8 9 10 11 12
Dr Nazir A. Zafar Advanced Algorithms Analysis and Design
Problem Statement
Problem Statement:
Given a set of m points, P = {p1, p2, . . . , pm}, in n-
dimension. Our objective is to compute a set of
maximal points i.e. set of points which are not
dominated by any one in the given list.
Mathematical Description:
Maximal Points =