in reply to fastest way to compare numerical strings?

Sort the array, then just compare consecutive values. Sorting speed is n*log(n) instead of n^2

b) If you don't mind some numbers reported twice and the values are all somewhat equally distributed over a fixed range you might seperate them into buckets and only compare all the numbers in each bucket. For example if all numbers are between 0.000000 to 9.9999999, you might generate 100 buckets, with the first bucket having all the numbers between 0.0 and 0.11, the second between 0.1 and 0.21 (the buckets have to overlap to catch the edge cases between two buckets). The speed is n+(n/100)^2*100, which might in some cases be lower than the sort solution.

  • Comment on Re: fastest way to compare numerical strings?