Foundations
Linear Structures
Hashing
Array and String Patterns
Recursion, Search, and Sorting
Problem Solving Patterns
Algorithm Searching
Sorting Algorithms
Array Algorithms
Grid Algorithms
Linear Structure Algorithms
Hashing Algorithms
Recursion and Backtracking
Greedy Algorithms
Tree and Heap Algorithms
Graph Algorithms
Dynamic Programming Algorithms
String Algorithms
Math Algorithms
Keyboard ready
Space plays. Arrow keys step. R restarts.
LAB Tries Lab
Trees
Concept shape
Core
Definition
A trie stores words by sharing prefixes through character nodes.
Step 1 / 5
Concept shape
Trees Core
Tries
Welcome to the Tries concept lab. A trie stores words by sharing prefixes through character nodes. The must know points are: Good for prefix queries. Each path represents a string prefix. Memory can be high for large alphabets. The common operations are: insert O(L), search O(L), startsWith O(L). The complexity shape is O(word length). Watch out for these pitfalls: Forgetting an end-of-word marker. Creating many sparse child maps. Related algorithms include Trie Insert and Search, Word Search.
Concept details
A trie stores words by sharing prefixes through character nodes.
Must know
- Good for prefix queries.
- Each path represents a string prefix.
- Memory can be high for large alphabets.
Complexity
O(word length)
1.0x