Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hash table vs Hash list vs Hash tree?

Tags:

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.

like image 290
Passionate programmer Avatar asked Jun 04 '10 13:06

Passionate programmer


People also ask

What is difference between hash table and tree?

Hash set and tree set both belong to the collection framework. HashSet is the implementation of the Set interface whereas Tree set implements sorted set. Tree set is backed by TreeMap while HashSet is backed by a hashmap. Sr.

Is HashList and Hashtable are same?

HashList is a data structure storing objects in a hash table and a list.it is a combination of hashmap and doubly linked list. acess will be faster. HashMap is hash table implementation of map interface it is same as HashTable except that it is unsynchronized and allow null values.

What is the main reason to use hash table instead of trees?

Hash tables have better time complexity bounds on search, delete, and insert operations in comparison to self-balancing binary search trees.


1 Answers

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

like image 199
Jack Avatar answered Nov 10 '22 05:11

Jack