简体   繁体   English

范围最小值/最大值查询

[英]Range Minimum/ Maximum Query

I have coordinate points (x,y) say I have 10 000 points .我有坐标点 (x,y) 说我有 10 000 points 。 now when a new point is given as test query say (p,q).现在当一个新的点作为测试查询给出时说(p,q)。 I have to check with every point in coordinate points.if x coordinate of text query that is PY from online searches I came to know that Rmq- range min/max query datastructure can help me but I am not sure how to do it..can some one help me how may i do this ..any references or code help in c++ will be of great help .thank you我必须检查坐标点中的每个点。如果来自在线搜索的 PY 文本查询的 x 坐标我开始知道 Rmq-范围最小/最大查询数据结构可以帮助我,但我不知道该怎么做。有人可以帮助我我该怎么做..c ++ 中的任何参考或代码帮助都会有很大帮助。谢谢

If your goal is to check whether the point exists in the data set, then there are a number of really useful data structures you could use to hold the data, each of which supports very efficient lookups.如果您的目标是检查数据集中是否存在该点,那么您可以使用许多非常有用的数据结构来保存数据,每个数据结构都支持非常有效的查找。

For starters, if all you need to know is whether or not the point exists, you could always store all the points in a standard hash table or balanced binary search tree.首先,如果您只需要知道该点是否存在,您始终可以将所有点存储在标准哈希表或平衡二叉搜索树中。 This would offer O(1) or O(log n) lookup time, respectively.这将分别提供 O(1) 或 O(log n) 的查找时间。 Plus these structures tend to be available in most programming languages.此外,这些结构往往在大多数编程语言中都可用。

If, on the other hand, you're planning on doing fancier operations on the data, such as searching for the k points in the data set nearest some test point, or trying to find all of the points in some bounding area, you might want to consider using a kd-tree or a quadtree .另一方面,如果您计划对数据进行更高级的操作,例如在数据集中搜索距某个测试点最近的 k 个点,或者尝试找到某个边界区域中的所有点,您可能会想考虑使用kd-treequadtree These variants on the standard binary search offer fast lookups (O(log n) time).标准二分搜索的这些变体提供快速查找(O(log n) 时间)。 The kd-tree also supports very fast k-nearest-neighbor searches and searches inside of bounding volumes. kd-tree 还支持非常快速的k-nearest-neighbor 搜索和边界体积内的搜索。 Moreover, the kd-tree is surprisingly easy to implement if you have any experience implementing a standard binary search tree.此外,如果您有任何实施标准二叉搜索树的经验,那么 kd-tree 非常容易实施。

Hope this helps!希望这可以帮助!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM