in reply to Re^2: Perl hit counter for multiple ranges, optimization or options in other languages?
in thread Perl hit counter for multiple ranges, optimization or options in other languages?

The algorithm I suggested is actually reading in parallel the data and the bin ranges. Therefore, it does just 1 comparison per line of data (plus one additional comparison each time the program crosses a bin range). The complexity is O(N). It will be very difficult to do anything better for N data records (at least if the data is sorted, which was my starting hypothesis; even if the data needs to be sorted, it is still likely to be the fastest solution if a good N Log N sorting program is used).

  • Comment on Re^3: Perl hit counter for multiple ranges, optimization or options in other languages?

Replies are listed 'Best First'.
Re^4: Perl hit counter for multiple ranges, optimization or options in other languages?
by MidLifeXis (Monsignor) on Aug 08, 2013 at 14:48 UTC

    Quite right. Coffee deficiency.

    --MidLifeXis