Find Closet Pairs -- To be continue
来源:互联网 发布:grace评分软件下载 编辑:程序博客网 时间:2024/05/17 01:57
Sweep line algorithm: a vertical line that is conceptually "swept" across the plane. To better understand this algorithm, it is better to compare it with divide-and-conquer
1: Closet Pair on the line (1-D)
Consider a set of points S on a line, the goal is to find which two of these points are minimally distant from each other. To solve this problem, we can partition this set into two parts by some point m. We call the left half as S,_1 right half as S_2, Assume that {p1, p2} are the points that is the closet pair in S_1, and {q1, q2} are the point that is the closet pair in S_2, d as the smaller of these two solutions. We can conclude that: There are three possibilities that might make the minimum distance d:
1: {p1, p2}, 2: {q1, q2}, 3: some pair {p3, q3} (p3 is from left half S_1, q3 is from right half S_2)
Key Observation: If the closet pair has one point from S_1 and one from S_2, then, both of these points must be within d of the midpoint m.
Final Observation: Since the minimum distance among the sub-solutions was d, there can be only a maximum of one point within d of m in each subsets. Hence, in order to see which of the three options is the correct closet pair, we need to test each pair of points to see if there is a pair {p3, q3} that defines a pair closer than d. The whole time complexity is NlgN.
2: Given a set of points {p1, ... pn} find the pair of points {pi, ... pj} that are closet together. (2-D)
First method: Divide and Conquer
Suppose we have the following points, and we first divide them into two parts. There are there possibilities: d is the smallest one, q is the smallest one or p is the smallest one. If d or p is the smallest one, we can get the minimum number through comparing d= min{d, p}, however, the trouble part is what if the q is the smallest one, the naive divide and conquer can't cover this case.
2: Given a set of rectangles, find the most overlapped points.
- Find Closet Pairs -- To be continue
- Scrum Introduction[To be continue...]
- Review C[To Be continue]
- The Lost Homeland【to be continue】
- Destroy, to be continue (2010-6-30)
- Asynchronous Programming Design Patterns (to be continue)
- 【to be continue】五金配件,省得以后不认识
- Google AJAX Search API Documentation (to be continue)
- 【To be continue】用过见过的芯片
- C语言常用代码(To be continue...)
- Linux上部署Redis集群(to be continue)
- Find zero pairs
- find the pairs
- find palindrome pairs
- find string in file (need to be improved)
- Configure the modules to be find by modprobe
- 【译】Why JavaScript Is and Will Continue to Be the First Choice of Programmers
- javaweb项目中对于资源文件的读取(to be continue)
- 如何将网站部署到IIS服务器上
- 算法复习笔记(回溯法,分支限界法)
- 冗余关系的判断_递归
- 七牛云存储使用笔记
- js 中 == 和 ===的区别
- Find Closet Pairs -- To be continue
- 常见排序算法
- React实战-深入了解JSX
- <c:forEach>跳出循环--JSTL
- Android bug之transformClassesWithDexForDebug
- Guava collections -- Ordering
- iOS图片加工---图片水印,图片裁剪和屏幕截图
- 【NOIP2010提高组】关押罪犯
- 解决configure: WARNING: You will need re2c 0.13.4 or later