Hash table: why buckets?

As far as I know, the point of the hash function is to distribute the data as evenly as possible, when you have a collision, you have several options:

  • Find the next empty slot
  • Create another hash and try pasting it elsewhere
  • Put it in an overflow container (maybe a list, another hash table or something else)
  • Place it in the next free bucket segment.

The latter bothers me, because if you are going to create a hash table with two slots for each address, why not just make a table with a lot of hashes? That is, if the buckets are not dynamically allocated. In my case, where the table data is on the disk, which would mean different disk access + variable length data management. It seems to me that buckets are still the most preferred option, why? What am I missing?

+4
source share
1 answer

As can be seen from the discussion in the comments on this subject, there are many different ways to implement a hash table. Everyone has their own compromises.

, ( ), ( ). , , , , , . . , , .

-, bucketing ( - - , - ), , , open : , , - -. , -, - - 1, 1 2. () , 1, - 1, 2, . , , . , A - 1, B - 2, C - 1. A, C, B :

[ A ] [ C ] [ B ] [   ] [   ]
  1     2     3

, C B, , B A C. .

, bucketing, , - , (- ) glacial . , , - , , , .

, !

+4

Source: https://habr.com/ru/post/1546239/


All Articles