3 ms·
In Java 8, collisions in Maps are stored in a tree structure so worst case is O(log n)
by sorokod 11y ago
In Java 8, collisions in Maps are stored in a tree structure so worst case is O(log n)
- logicchains 11y agoIs it a balanced tree? If not, worst case could still be O(n).
- Rapzid 11y agoHaha, that would be an odd set of data indeed. I have no idea how they implement it but I hope I have made a point(I feel I have). I wouldn't be too impressed with an interviewer or interviewee arguing one side or the other about the complexity of "unspecified hashmap implementation". Too clever by half.