散列算法,其用途? [英] Hashing Algorithm, its uses?

查看:109
本文介绍了散列算法,其用途?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我不完全理解哈希算法。任何人都希望以一种非常容易理解的方式向我解释它。

I don't fully understand hashing algorithms. Anybody care to explain it to me in a very simply understandable way.

谢谢

编辑:将其与文本文件中的用户名。

Using it with Usernames from a text file.

推荐答案

散列算法,但是基本思想是快速(几乎)唯一地为数据片段提供标识符。然后可以将其用作表的索引,以便可以快速查找数据。大多数散列算法都有冲突,其中两个数据将散列为相同的值,但这对于最佳算法来说是极为罕见的。

There are a lot of hashing algorithms, but the basic idea is to quickly and (nearly) uniquely come up with an identifier for a piece of data. This can then be used as an index into a table so that data can be quickly looked up. Most hash algorithms have collisions, where two pieces of data will hash to the same value, but this is extremely rare for the best algorithms.

很有用,比方说,我为我的城市散列了整个电话簿。现在,当我想查找某人的电话号码时,无需执行二进制搜索,而是通过哈希算法运行其姓名,然后直接 进入表中的该索引。

For an example of why this might be useful, let's say I hashed the entire phone book for my city. Now instead of doing a binary search when I want to look up someone's number all I have to do is run their name through the hashing algorithm then go directly to that index in my table.

这篇关于散列算法,其用途?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆