Trie Data Structure: Overview and Practice Problems
Published in
2 min readDec 23, 2018
Trie is a tree-based data structure, used for efficient retrieval of a key in a large data-set of strings. Unlike a binary search tree, where the node in the tree stores the key associated with that node, the Trie node’s position in a tree defines the key with which it is associated, and the key is only associated with the leaves. It is also known as prefix tree as all descendants of a node have a common prefix of the string associated with that node, and the root is associated with the empty string.
Following are the list of commonly asked Trie interview questions:
- Trie Implementation — C, C++, C++ (Memory Efficient), Java, Python
- Longest Common Prefix in a given set of strings (using Trie)
- Lexicographic sorting of a given set of keys
- Find the maximum occurring word in a given set of strings
- Find first `k` maximum occurring words in a given set of strings
- Find duplicate rows in a binary matrix
- Word Break Problem — Using Trie Data Structure
- Generate a list of possible words from a character matrix
- Find all words matching a pattern in the given dictionary
- Find the shortest unique prefix for every word in an array
Thanks for reading.