What is an associative field?

Associative field, also called a hash table or hash map, is similar to the standard field, except for the field index, the string may be instead of the entire whole number. In many database applications and in other programs dealing with a large amount of data, the associative field is an essential element that helps efficient sorting and access to information. The core of the associative field is a standard field that is indexed with integers, as it would usually be. A special algorithm called and Hash Function converts the string index into an interregional index to determine the value. This is a consistent conversion, so the actual integer index may never be stored, but instead it is calculated from the string each time. What would normally be called the index - a numerical location of the element inside the field - with a call. The key -related data is called a value. This means that within an associative field, the key is associated with the value that correlates with an index referring to an element in a standard field in a structurethe data of the data.

In the heart of each associative field is a hash function. This is the algorithm used to determine the numeric index of the key -based value. There are several types of hash functions, some intended for keys that are integers, and some designed to work on the keys that are chains. In the case of an integer key, it is a popular method to divide the value of the key size and the rest of the division, hopefully to obtain a unique index value.

The hash function can be much more complicated for the keys that are strings. Some methods include adding the numeric values ​​of each character to the string, and then by dividing it by a number, or using only the first few characters of the string you get a unique number. There are many ways to derive a number from the character string.

6 collision happens when the integer is an index derived from the key identical to the integer indexo keys. These two keys then effectively point to the same index in the value field. There are different solutions to collision, mainly because it has a high probability that it will happen in most practical applications.

One of the collision solutions is that each index of values ​​is a truly connected list, so if more than one key is resolved to this index location, the location can hold more than one value. This is called chaining, and it is a simple way to manipulate collision, even if it can also slow down the time to get information. Another method of collision is called linear probes. When there is a collision, linear probing works by moving around the value field until the index is found. This solution can help keep the data evenly distributed in the associative field, but it can also extend the amount of time required to find the value.

IN OTHER LANGUAGES

Was this article helpful? Thanks for the feedback Thanks for the feedback

How can we help? How can we help?