At first I found this tricky, as the number of strings in the array is
unknown, and it can be hard to iterate over unknown items of unknown
length. Since repeated combinations are included, we know the total number
of combinations (lengths of all strings multiplied). In my Ruby example
below, I
AND, for two points to be close, they need not be on the same quadrant
On Dec 21, 10:55 pm, atul anand atul.87fri...@gmail.com wrote:
to find all points which lies on the same quadrant for a specific node(say
1) , we have to check all nodes...rite??
we have to find difference b/w 2 node(frome
@Gene,
The algorithm which you have given below is O(n^2). I tried too and could
not figure out anything better than this unless we go for data structures
like kd-trees, as you already suggested.
Is it really the case that w/o using kd-tree, there is no better algorithm?
On Fri, Dec 23, 2011 at
@Gene -
Cool algorithm! I tried before in java and messed a little to get exact
output format.
Just wondering how you came up with simple yet working code?
-Carol
On Thu, Dec 22, 2011 at 6:08 PM, Gene gene.ress...@gmail.com wrote:
The simplest algorithm is probably to check each point against
The simplest algorithm is probably to check each point against all
others while maintaining a list of the top 3. Since 3 is a small
number, you can just maintain the top 3 in sorted order by insertion.
For a bigger K top-K you'd use a max heap.
This can also be done in O(n log n) time by building