Pergunta

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

Foi útil?

Solução

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.

Licenciado em: CC-BY-SA com atribuição
scroll top