Is this n-body problem O(n^2) or O(n log n)?
问题 I'm writing an article on the n-body problem, and I'd like to be technically accurate. The code is here. And here are the comments and loops: /** * Given N bodies with mass, in a 3d space, calculate the forces of gravity to be applied to each body. * * This function is exported to JavaScript, so only takes/returns numbers and arrays. * For N bodies, pass and array of 4N values (x,y,z,mass) and expect a 3N array of forces (x,y,z) * Those forcess can be applied to the bodies mass to update the