|
March 18, 2000 The trie Data Structure Tips: March 2000
Yehuda Shiran, Ph.D.
|
|
The trie data structure is included in the curriculum of most computer science programs. The origin of the name is from the middle section of the word "retrieval", and this origin hints on its usage: information retrieval systems. Program designers use this data structure to build systems that can extract information in a computational complexity order of one, which is, of course, the best that one can have. The trie data structure is based on two principles: a fixed set of indices and hierarchical indexing. The first requirement is usually met when you can index the data by some or all of the digits 0 to 9, or by the alphabet. For example, let's take the ten digits 0 to 9. At the top level you have a 10-element array. Each of these array's elements may point to another 10-element array, and so on. If you index the data by the alphabet, there will be 26 elements at the top level array, and each element will point to another 26-element array, and so on. One of the advantages of the trie data structure is that its hierarchy depth depends on the amount of data stored in it. Each element of data is stored at the highest level of the hierarchy that still allows a unique retrieval. As the data structure getting loaded with data, former data elements lose their uniqueness and need to be pushed down the hierarchy. Thus, the more data being loaded the deeper the hierarchy will be.
Let's take an example. Suppose we have an element that can be identified by the sequence 8376. Assume also that the trie data structure consists of the Learn about our trie-based dialer in Column 57, The Doc Dialer, Part I: Introduction.
People who read this tip also read these tips: Look for similar tips by subject: |