Given my recent (somewhat successful) question:
http://stackoverflow.com/questions/3387274/algorithmic-issue-determining-user-sessions
I'm pretty sure that the way to solve it cleanly is to use a balanced binary tree (which would give an n log m solution to the problem, where thankfully the m is going to be quite small, even tiny, compared to the n), like hinted by one of the answer (answer which comes with some pseudo-code).
My question is simple: does the default Java API have a self-balancing tree?
If not, do you know of any implementation of such a tree (Apache, Google collections, anything)?
If nothing looks suitable, what would be the best tree to start with to implement such a balanced binary tree?