user3245689
user3245689

Reputation: 157

algorithm implementation compare with c++ and php

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.

  1. For each points find nearest neightbour using euclidian distance formula sqrt[(x2-x1)^2 - (y2 - y1)^2]
  2. Point which appears maximum times as nearest neighbour should be marked as dense/center point

I have two alternatives.

  1. Sending coordinate values to c++ compiled executable server process which performs above task and return resulting value
  2. perform above processing in php script itself to get the result

Can some one tell me which one is faster and appropriate?

Upvotes: 0

Views: 84

Answers (1)

Chethan N
Chethan N

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

Related Questions