Why the search time for TreeSet is O(nlogn)?
https://softwareengineering.stackexchange.com/questions/334613
-
31-12-2020 - |
Pergunta
In my naive opinion it should be O(n) in worst case since Tree could get spindly and unbalanced.
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
Não afiliado a softwareengineering.stackexchange