I am trying to create a method that counts how many collision occur in a hash table. Would I check the entire table to see how many buckets have more than 1 element?
Draft:
public int getCollisions() { int counter = 0; for (int i = 0; i < buckets.length; i++) { if (buckets.length > 1) { counter += i; } } return counter; }
if (bucket.length > 1) { counter += bucket.length; }