Open In App

Hash Table vs Trie

What is Hash Table?

An array that stores pointers to records corresponding to a given element. An entry in the hash table is NIL if no existing element has a hash function value equal to the index for the entry.  In simple terms, we can say that a hash table is a generalization of the array. Hash table gives the functionality in which a collection of data is stored in such a way that it is easy to find those items later if required. This makes searching for an element very efficient.

Advantages of Hash Table over Trie:

Disadvantages of Hash Table over Trie:

Applications of Hash Table:

Complexity analysis of Hash Table:

What is Trie?

Trie data structure is defined as a Tree based data structure that is used for storing some collection of strings and performing efficient search operations on them. The word Trie is derived from retrieval, which means finding something or obtaining it.



Trie follows some property that If two strings have a common prefix then they will have the same ancestor in the trie. A trie can be used to sort a collection of strings alphabetically as well as search whether a string with a given prefix is present in the trie or not.

Advantages of Trie over Hash Table:

Disadvantages of Trie over Hash Table:

Applications of Trie: 

Complexity analysis of Trie:



Compare the Lookup operation of HashTable vs Trie:

HashTable

Trie:

Article Tags :