D
D
DarkByte20152017-01-25 19:42:53
C++ / C#
DarkByte2015, 2017-01-25 19:42:53

How are hash tables arranged?

I was puzzled by the issue of hash tables. Found this article . I didn’t really understand about closed addressing (there is also an example in Pascal ... and not complete). But the main thing - do I understand correctly that hash tables are strictly limited in size? Those. a hash table as a static array - how many elements will you create as many and will it be impossible to increase its size in the future? Judging by the algorithm that is given there, this is so ...
PS So, by the way, what algorithm is better? With open or closed addressing?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
Rsa97, 2017-01-25
@Rsa97

Open and closed addressing (in the terms of this article) differ in their behavior in the event of a collision, that is, adding an entry to the hash table with a hash already in it.
With open addressing, a dynamic list will be created, the head of which is in the corresponding cell of the hash table, and the elements will be the hashed data (or pointers to them).
When closed, there will be an attempt to find a free cell to the left (or to the right, depending on the implementation) of an already occupied cell, into which the hash and hashed data will be written.
Obviously, the open version is somewhat more difficult to implement, but at the same time much more flexible and well extensible. The advantage is that having received a hash by simply iterating over the list, we can get all the values ​​​​with such a hash.
The closed version has a fixed memory consumption and a simpler implementation, but with numerous collisions it gives low efficiency, since you have to iterate through the cells in search of values ​​with the desired hash.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question