Anonymous user
K-d tree: Difference between revisions
m
Made the code compilable on gcc and g++ versions 4.8, code looks better now hopefully
m (Made the code compilable on gcc and g++ versions 4.8, the thisn is a bit ugly though.) |
m (Made the code compilable on gcc and g++ versions 4.8, code looks better now hopefully) |
||
Line 55:
return d;
}
}
Line 149:
{{2, 3}}, {{5, 4}}, {{9, 6}}, {{4, 7}}, {{8, 1}}, {{7, 2}}
};
struct kd_node_t
struct kd_node_t *root, *found, *million;
double best_dist;
Line 157:
visited = 0;
found = 0;
nearest(root, &
printf(">> WP tree\nsearching for (%g, %g)\n"
"found (%g, %g) dist %g\nseen %d nodes\n\n",
found->x[0], found->x[1], sqrt(best_dist), visited);
Line 169:
root = make_tree(million, N, 0, 3);
rand_pt(
visited = 0;
found = 0;
nearest(root, &
printf(">> Million tree\nsearching for (%g, %g, %g)\n"
"found (%g, %g, %g) dist %g\nseen %d nodes\n",
found->x[0], found->x[1], found->x[2],
sqrt(best_dist), visited);
Line 194:
found = 0;
visited = 0;
rand_pt(
nearest(root, &
sum += visited;
}
Line 206:
return 0;
}
</lang>
{{out}}
|