A trie is a tree-like information retrieval data structure whose nodes store the letters of an alphabet. It is also known as a digital tree or a radix tree or prefix tree. Tries are classified into three categories:

** Standard Trie** A standard trie have the following properties:

- A Standard Trie has the below structure:
class Node { // Array to store the nodes of a tree Node[] children = new Node[26]; // To check for end of string boolean isWordEnd; }

- It is an ordered tree like data structure.
- Each node(except the
**root**node) in a standard trie is labeled with a character. - The children of a node are in alphabetical order.
- Each node or branch represents a possible character of keys or words.
- Each node or branch may have multiple branches.
- The last node of every key or word is used to mark the end of word or node.

Below is the illustration of the Standard Trie:

** Compressed Trie** A Compressed trie have the following properties:

- A Compressed Trie has the below structure:
class Node { // Array to store the nodes of tree Node[] children = new Node[26]; // To store the edgeLabel StringBuilder[] edgeLabel = new StringBuilder[26]; // To check for end of string boolean isEnd; }

- A Compressed Trie is an advanced version of the standard trie.
- Each nodes(except the
**leaf**nodes) have atleast 2 children. - It is used to achieve space optimization.
- To derive a Compressed Trie from a Standard Trie, compression of chains of redundant nodes is performed.
- It consists of grouping, re-grouping and un-grouping of keys of characters.
- While performing the insertion operation, it may be required to un-group the already grouped characters.
- While performing the deletion operation, it may be required to re-group the already grouped characters.
- A compressed trie T storing s strings(
**keys**) has s external nodes and O(s) total number of nodes.

Below is the illustration of the Compressed Trie:

** Suffix Trie** A Suffix trie have the following properties:

- A Compressed Trie has the below structure:
struct SuffixTreeNode { // Array to store the nodes struct SuffixTreeNode *children[256]; //pointer to other node via suffix link struct SuffixTreeNode *suffixLink; // (start, end) interval specifies the edge, // by which the node is connected to its // parent node int start; int *end; // For leaf nodes, it stores the index of // Suffix for the path from root to leaf int suffixIndex; }

- A Suffix Trie is an advanced version of the compressed trie.
- The most common application of suffix trie is Pattern Matching.
- While performing the insertion operation, both the word and its suffixes are stored.
- A suffix trie is also used in word matching and prefix matching.
- To generate a suffix trie, all the suffixes of given string are considered as individual words.
- Using the suffixes, compressed trie is built.

Below is the illustration of the Suffix Trie:

## Recommended Posts:

- Types of Normal Forms in DBMS
- R - Data Types
- Types and Applications of LED
- Types of Static Analysis Methods
- Types of Cache Misses
- Types of Array Processor
- Automation and its Types
- Node having maximum number of nodes less than its value in its subtree
- Queries to count array elements greater than or equal to a given number with updates
- Maximize sum of array by reducing array elements to contain no triplets (i, j, k) where a[i] < a[j] and a[i] < a[k] and j <i < k
- Queries to find Kth greatest character in a range [L, R] from a string with updates
- Classification of Mobile Communication
- Search strings with the help of given pattern in an Array of strings
- Find value after N operations to remove N characters of string S with given constraints

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.