Home java Containers in Java

Containers in Java

Author

Date

Category

What standard containers allow you to find an element in them by its value for O (log (n))?


Answer 1, Authority 100%

hashset / hashmap has asymptotics O (1) at best, in the case of conflicts, there works or a list or tree (if the values ​​in one node are greater than 8, if not mistaken) and in this case it may well succeed and O (log ( n)) in the worst case.

If you need a collection that an average of O (log (n)), TreeSet / TreeMap is built on a tree, therefore most likely we are talking about them. Or do you need all possible containers in Java with access to O (log (n))? Interested in collections from any guava and apache (all sorts of Patriciatrie and TreeList) or speech only about JDK?

If you are interested in more about the collection, look this article .

Programmers, Start Your Engines!

Why spend time searching for the correct question and then entering your answer when you can find it in a second? That's what CompuTicket is all about! Here you'll find thousands of questions and answers from hundreds of computer languages.

Recent questions