Tries: Supporting a Variety of Data
Learn about the different types of tries through examples demonstrating the creation of tries for different sets of data.
We'll cover the following
We know that a trie is an
We'll learn about the different types of tries constructed on different datasets through examples.
Trie of alphabet
We can represent strings as a trie of letters of alphabet or characters, which can be used to implement features like search-autocomplete or creating dictionaries.
For example, a trie of words ["app", "apple", "appeal", "apply", "ape"]
would look like the figure below.
Trie of words
Sentences can be represented as a trie of words. The tries are used for pattern matching in text and finding frequently used words and phrases.
For example, a trie of sentences ["Ben has two books", "Ben has two games", "Ben has three bats"]
would look like the figure below.
Trie of bits
Binary numbers can be represented as a trie of bits. These tries can be used to perform range queries like finding the maximum XORÂ of binary digits in a list.Â
For example, a trie of binary numbers ["10110", "11001", "10101"]
would look like the figure below.
Trie of directory paths
Directory paths can be represented as a trie of folder and file names. These tries can be used to design a file system that allows us to create new paths, associate them with different values, and visualize the directory structure of a system.
For example, a trie of directory paths ["home/user/William/file1", "home/user/William/file2", "home/user/Ben/file1"]
would look like the figure below.