Hash table – what is the point of a hash table?

I have no experience with hash tables outside of arrays / dictionaries in dynamic languages, so I recently found that internally, they are implemented by using the hash of keys and use it to store the value What I don't understand is why I don't store the key (string, number, any) as the value of well key, rather than as its hash and storage

Solution

Why do we use a hashcode in a hashtable instead of an index?

Novel, you can check whether a key has been stored very quickly and quickly store a new mapping at the same time Otherwise, you must keep a sorted list of keys in order to store and retrieve mappings

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>