Trie achieves **efficiency** through **prefix sharing**, which means common prefixes of different words are stored only once.
---
Because of prefix sharing usage, it’s possible to save memory space as you need fewer space to store the data - some word’s prefixes could be reused.
Considering two words:
- car
- can
for these two the common prefix is `ca`, so Trie would look like this:
```
root
|
c
|
a
/ \
r n
```
That way you're able to store these two words using 5 nodes, instead 6.
---
Tries enables **fast lookups** by following the character paths until either - finding the end of a valid word or determining the word doesn’t exist.
It’s effective when using it for prefix-based operations like finding all words that start with a given prefix (i.e.: „give me all words that starts with „comp”)
---
Fast lookup is beneficial for **ip lookups in routing tables**. It’s common to see the variations of Trie in Router’s routing tables.
### See also
1. [[What is Trie?]]