What is hash primary and secondary clustering?

In the past few days, I am confused about finding the difference between primary and secondary clustering in the topic of hash collision management in the tutorial I'm reading.

+8
algorithm data-structures hash linear-probing quadratic-probing
source share
2 answers

Primary clustering means that if the cluster and the starting position of the new record fall anywhere in the cluster, the cluster size will increase. Linear sounding leads to this type of clustering.

Secondary clustering is less severe, two records have only one collision chain, if their initial position is the same. For example, quadratic sounding leads to this type of clustering.

+8
source share

I did research and would like to share some notes:

  • Primary clustering is a trend in a collision resolution scheme, such as linear sensing, to create long runs of filled slots next to the hash position of the keys.
  • If the primary hash index is x , subsequent probes go to x+1 , x+2 , x+3 , etc., this leads to primary clustering.
  • As soon as the main cluster is formed, the more the cluster receives, the more it grows faster. And it reduces performance.

enter image description here


  • Secondary clustering is a trend in a collision resolution scheme, such as quadratic probing, to create long runs of filled slots from the hash position of the keys.
  • If the primary hash index is x , then the probes go to x+1 , x+4 , x+9 , x+16, x+25 , etc., this leads to secondary clustering.
  • Secondary clustering is less rigid in terms of performance than primary clustering, and is try to keep clusters from forming using Quadratic Sensing. The idea is to examine more widely separated cells, rather than those next to the main hash site.

enter image description here

+31
source share

All Articles