Reputation: 33
A treeset is already sorted... so why isn't the time complexity to remove an object O(Log N) through binary search? Am I missing something?
Upvotes: 0
Views: 813
Reputation: 6573
It is O(log N) according to the JavaDocs for TreeSet:
This implementation provides guaranteed log(n) time cost for the basic operations (add, remove and contains).
Upvotes: 1