HashSet is probably the most popular implementation of a set in Java. An important reason of that is computational complexity of crucial operation on HashSet. Check sixty fith question of full-stack dev quiz to find out, if you know what that means.
What computational complexity the contains method has of HashSet?
Choose all valid answers.
- O(1)
- O(n)
- O(n logn)
- constant
- linear
- logarithmic
For the correct answer scroll down
.
.
.
.
.
.
The correct answer is: a,d. If you would like to read more, check Is it worth using HashSet for a few elements? article.