366人阅读 评论(0)

# 查找操作（Searching）

%% range query的函数
function findAll = rangeQuery(obj,id,rect)
% obj是一个k-d tree的对象，id是从某个id开始查起，用于实现递归，rect是待查区间
left = obj.nodeCell{id}.leftID;
right = obj.nodeCell{id}.rightID;
findLeft = [];
findRight = [];

if (isempty(left)==0) && (interRegion(obj.nodeCell{left}.region,rect,obj.dimen)==1)
% 左非空，且左有子集，向左搜索
findLeft = rangeQuery(obj,left,rect);
end

if (isempty(right)==0) && (interRegion(obj.nodeCell{right}.region,rect,obj.dimen)==1)
% 右非空，且右有子集，向右搜索
findRight = rangeQuery(obj,right,rect);
end

if interPoint(rect,obj.nodeCell{id}.point,obj.dimen)==1
% 当前点在range内
findAll = [id,findLeft,findRight];
else
findAll = [findLeft,findRight];
end

end

# 优化操作（Optimize）

Ref.
[Ben75] Bentley, J. L. (1975). Multidimensional binary search trees used for associative searching. Communications of the ACM, 18(9), 509-517.
[FBF77] Friedman, J. H., Bentley, J. L., & Finkel, R. A. (1977). An algorithm for finding best matches in logarithmic expected time. ACM Transactions on Mathematical Software (TOMS), 3(3), 209-226.
[LW77] Lee, D. T., & Wong, C. K. (1977). Worst-case analysis for region and partial region searches in multidimensional binary search trees and balanced quad trees. Acta Informatica, 9(1), 23-29.
[Rob81] Robinson, J. T. (1981, April). The KDB-tree: a search structure for large multidimensional dynamic indexes. In Proceedings of the 1981 ACM SIGMOD international conference on Management of data (pp. 10-18). ACM.

0
0

* 以上用户言论只代表其个人观点，不代表CSDN网站的观点或立场
个人资料
• 访问：41553次
• 积分：686
• 等级：
• 排名：千里之外
• 原创：20篇
• 转载：0篇
• 译文：1篇
• 评论：18条
阅读排行
最新评论