Home  >  Article  >  What is the hash construction method for string keywords?

What is the hash construction method for string keywords?

藏色散人
藏色散人Original
2020-07-02 09:45:382327browse

The hash construction method of string keywords is "ASCII code addition method", and the algorithm statement is "h(key) = (Σkey[i]) mode TableSize".

What is the hash construction method for string keywords?

Hash construction of string keywords

ASCII code addition method

h(key) = (Σkey[i]) mode TableSize

Related introduction:

Hash table (also called hash Table) is a data structure that is directly accessed based on the key value. That is, it accesses records by mapping key values ​​to a location in the table to speed up lookups. This mapping function is called a hash function, and the array storing the records is called a hash table.

Given table M, there is a function f(key). For any given keyword value key, if the address of the record containing the keyword in the table can be obtained after substituting the function, it is called table M. is a Hash table, and function f(key) is a Hash function.

The above is the detailed content of What is the hash construction method for string keywords?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn