In Java HashSet
, when a collision occurs, the HashMap
stores multiple entries in the same bucket using a linked list.
Then in the case of LinkedHashSet
, LinkedHashMap
will have a pointer to the next inserted element as well.
So, does each entry object have multiple pointers - one to point the elements in the same bucket and the other to point to the next inserted element?
Technically, there are also pointers to the key and to the value. Look at the implementation and decide how many pointers count.
The answer you're probably looking for is three: one to the next in the bucket, one to the previous entry in insertion order, and one to the next entry in insertion order.