Hash table vs Hash list vs Hash tree?

久未见 提交于 2019-12-03 03:47:36

问题


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.


回答1:


  • 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..



来源:https://stackoverflow.com/questions/2974597/hash-table-vs-hash-list-vs-hash-tree

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!