![]() |
VOOZH | about |
Trie(also known as the digital tree or prefix tree) is a sorted and efficient tree-based special data structure that is used to store and retrieve keys in a dataset of strings. The basic ideology behind this is retrieving information. It is based on the prefix of a string. It can be visualized as a graph consisting of nodes and edges. Another name for Trie is the digital tree. Each node of a trie can have as many as 26 pointers/references. These 26 pointers represent the 26 characters of the English language.
Basic Operations of Trie:
It has a wide variety of applications in data compression, computational biology, longest prefix matching algorithm used for routing tables for IP addresses, implementation of the dictionary, pattern searching, storing/querying XML documents, etc.
1. Browser History: Web browsers keep track of the history of websites visited by the user So when the prefix of a previously visited URL is written in the address bar the user would be given suggestions of the website to visit.
Trie is used by storing the number of visits to a website as the key value and organizing this history on the Trie data structure
2. AutoComplete: It is one of the most important applications of trie data structure. This feature speeds up interactions between a user and the application and greatly enhances the user experience. Auto Complete feature is used by web browsers, email, search engines, code editors, command-line interpreters(CLI), and word processors.
Trie provides the alphabetical ordering of data by keys. Trie is used because it is the fastest for auto-complete suggestions, even in the worst case, it is O(n) (where n is the string length ) times faster than the alternate imperfect hash table algorithm and also overcomes the problem of key collisions in imperfect hash tables.
3. Spell Checkers/Auto-correct: It is a 3-step process that includes :
Trie stores the data dictionary and makes it easier to build an algorithm for searching the word from the dictionary and provides the list of valid words for the suggestion.
4. Longest Prefix Matching Algorithm(Maximum Prefix Length Match): This algorithm is used in networking by the routing devices in IP networking. Optimization of network routes requires contiguous masking that bound the complexity of lookup a time to O(n), where n is the length of the URL address in bits.
To speed up the lookup process, Multiple Bit trie schemes were developed that perform the lookups of multiple bits faster.