Reputation: 157
I am getting (x,y)
coordinates value from MySQL table. Suppose there are 50 such points.
I want to apply nearest neighborhood algo on these points to get most central/dense points among all.
sqrt[(x2-x1)^2 - (y2 - y1)^2]
I have two alternatives.
Can some one tell me which one is faster and appropriate?
Upvotes: 0
Views: 84
Reputation: 1158
It is well known that PHP is slower than C++. But for small number of computations it really does not matter. In your case the algorithm has complexity O(n^2)
. For about 50 points ( as mentioned in the question ) it is not recommend to use C++ for this purpose as the overhead created by making the system is more compared to benefits you get.
If you have huge calculations to be done you may go for C++.
Have a look at this, it may help you.
Upvotes: 1