Mental Model
A trie stores strings by sharing common beginnings, making prefix searches fast and memory efficient. Hash maps store whole strings separately, missing this shared structure.
Analogy: Imagine a tree of roads where each letter is a turn. Many roads share the same first turns before splitting. A trie is like this road map, saving space by sharing paths. A hash map is like separate maps for each road, repeating the same first turns over and over.
root
├─ c
│ ├─ a
│ │ ├─ t (end)
│ │ └─ r (end)
│ └─ o
│ └─ w (end)
└─ d
└─ o
└─ g (end)