哈希表与哈希表vs哈希树

哈希表与哈希表vs哈希树

本文介绍了哈希表与哈希表vs哈希树?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

什么属性使哈希表,哈希列表和哈希树彼此不同?何时使用哪一个?什么时候表优于树。

解决方案


  • Hashtable 数据结构,其中可以插入(key,value)对,使用该键来计算需要决定在哪里存储与其关键字关联的值的哈希码。这种结构是有用的,因为计算哈希码是O(1),所以你可以找到或放置一个项目在不断的时间。 (请注意,有一些注意事项和不同的实现会稍微改变这种性能)

  • Hashlist :它只是在各种数据块上计算的哈希码列表。例如:您分割了许多部分的文件,并为每个部分计算一个哈希码,然后将其全部存储在列表中。然后,您可以使用该列表来验证数据的完整性。

  • Hashtree :它类似于哈希列表,而不是一个哈希值列表,你有一棵树,所以树中的每个节点都是一个哈希码,它是根据孩子计算的。当然,叶子将是您开始计算哈希码的数据。



Hashtable 通常是有用的它们也被称为 hashmaps ),而哈希列表哈希表对于确切的目的而言更具体和有用。


What property makes Hash table, Hash list and Hash tree different from each other? Which one is used when? When is table superior than tree.

解决方案

  • Hashtable: it's a data structure in which you can insert pairs of (key, value) in which the key is used to compute an hashcode that is needed to decide where to store the value associated with its key. This kind of structure is useful because calculating a hashcode is O(1), so you can find or place an item in constant time. (Mind that there are caveats and different implementations that change this performance slightly)
  • Hashlist: it is just a list of hashcodes calculated on various chunks of data. Eg: you split a file in many parts and you calculate a hashcode for each part, then you store all of them in a list. Then you can use that list to verify integrity of the data.
  • Hashtree: it is similar to a hashlist but instead of having a list of hashes you have got a tree, so every node in the tree is a hashcode that is calculated on its children. Of course leaves will be the data from which you start calculating the hashcodes.

Hashtable is often useful (they are also called hashmaps) while hashlists and hashtrees are somewhat more specific and useful for exact purposes..

这篇关于哈希表与哈希表vs哈希树?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-14 23:51