Worse case time complexity put/get HashMap

前端 未结 5 1987
后悔当初
后悔当初 2021-02-10 22:41

What is the worst case time complexity of an Hashmap when the hashcode of it\'s keys are always equal.

In my understanding: As every key has the same hashcode it will al

5条回答
  •  醉酒成梦
    2021-02-10 23:47

    In Java 8's HashMap implementation:

    Handle Frequent HashMap Collisions with Balanced Trees: In the case of high hash collisions, this will improve worst-case performance from O(n) to O(log n).

    From here.

提交回复
热议问题