Words share a start
transcript
A million words. Many start the same. Why store the start again and again? A trie stores it once, as one shared path. Let us see how.
Car and cat both start with c a. So they share the nodes c and c a. Then the words split into r and t. Each edge is one letter. Each node is a start.
Add the word cow. It shares only the letter c. Six nodes hold nine letters. The more words share, the more you save.
Walk the letters the words share. Branch where the words differ. Each shared start is stored once. The more they share, the more you save. Names and paths share long starts. A million words may need far fewer nodes than letters.
Shared starts cost nothing extra. Autocomplete is built on this. So are spell checkers and routers. Build it yourself in the lab. Full breakdown in the lecture.