In my naive opinion it should be O(n) in worst case since Tree could get spindly and unbalanced.

有帮助吗?

解决方案

TreeSet is based on TreeMap, which is a Red-Black Tree implementation. Red-Black Trees are self-balancing binary search trees that guarantee O(log n) performance for search, insert and delete operations.

许可以下: CC-BY-SA归因
scroll top