失效链接处理 |
kdtrees文档 PDF 下载
本站整理下载:
相关截图:
![]()
主要内容:
Insert Code
insert(Point x, KDNode t, int cd) {
if t == null
t = new KDNode(x)
else if (x == t.data)
// error! duplicate
else if (x[cd] < t.data[cd])
t.left = insert(x, t.left, (cd+1) % DIM)
else
t.right = insert(x, t.right, (cd+1) % DIM)
return t
}
FindMin in kd-trees
• FindMin(d): find the point with the smallest value in
the dth dimension.
• Recursively traverse the tree
• If cutdim(current_node) = d, then the minimum
can’t be in the right subtree, so recurse on just the
left subtree
- if no left subtree, then current node is the min for tree
rooted at this node.
• If cutdim(current_node) ≠ d, then minimum could
be in either subtree, so recurse on both subtrees.
- (unlike in 1-d structures, often have to explore several
paths down the tree)
|