I am interested in such a question: as we know, Red-Black tree provides efficient implementation of such operations as successor (the first element higher that entry) and predecessor , i.e. in log – time.
In Java documentation is written that for providing such operation as successor you may merely use subSet and then took the least element in the subSet. But is it log-time? If it is, what is the implementation of subSet?(I am interested in the algorithm, so it may be just few words, not necessary code)
Thanks.
I would just read the code to see how it works.
I believe subSet is O(log N) A more natural approach would be to use the
lower(E)andhigher(E)methods which is designed to do this.http://docs.oracle.com/javase/7/docs/api/java/util/NavigableSet.html