Implementing A Trie In JavaScript

Recently, I encountered a situation where I need to perform text searches in a large set of data. Normally, I would do it in a filter function, but that would be slow when the list is too long. There’s a data structure for this situation. Meet the Trie! Trie (pronounced try) is a tree-like data structure that’s created for efficient text searches. How does it work Trie takes all words and rearranges them in a tree hierarchy. For example, the list of words ['abet', 'abode', 'abort'] will be transformed into a structure like this: ...

January 4, 2020 · 6 min · Lei Huang