首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

Kd Tree解决方案

2013-07-04 
Kd Tree最近在学习Kd tree。http://rosettacode.org/wiki/K-d_tree#C但是上面链接中的程序中好像有错,同一

Kd Tree
最近在学习Kd tree。
http://rosettacode.org/wiki/K-d_tree#C
但是上面链接中的程序中好像有错,同一给数据,只是顺序不同,得到的结果不同,而且有一个结果还是错误的。
我的测试数据如下:
输入
{{1, 0, 0}}, {{1, 1, 0}}, {{0, 1, 0}}, {{0, 0, 0}}
结果错误

输入
{{0, 0, 0}}, {{1, 0, 0}}, {{1, 1, 0}}, {{0, 1, 0}}
结果正确

现在猜测可能是find_median()函数出现问题。
求各位大神指点。 C++?Kd?tree
[解决办法]
对于你的测试数据
{{1, 0, 0}}, {{1, 1, 0}}, {{0, 1, 0}}, {{0, 0, 0}}
你搜索什么数据后得到什么错误结果?

我试搜索{{0, 2, 0}},得到:
>> WP tree
searching for (0, 2)
found (0, 1) dist 1
seen 2 nodes

热点排行