[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: shaving microseconds (avoiding N * logN behavior)



PureBytes Links

Trading Reference Links


: I've got a system that does an EXPENSIVE calculation
: and right now I'm using an algorithm with O(N * logN)
: asymptotic behavior.  I hope somebody can offer a
: suggestion on how to reduce this to O(N), or better
: yet, O(logN).
: 
: Problem: for each day in the dataset, look back at
:          the N most recent trading days and return the
:          K'th largest Open price among those N bars.


How about a simple binary search with 3 way comparision? That's O(log N).