DEV Community

loading...

Discussion on: Building a Discord bot to filter out swear words

Collapse
larsks profile image
Lars Kellogg-Stedman • Edited

Why a Trie instead of the native set data type? set will give you O(1) lookups, which beats the O(L) lookup time of the Trie, and you're not dealing with a large enough dataset that relative memory efficiency is going to matter, even if there is a difference.

Collapse
nldoty profile image
Nick Doty Author

Because when you have a lot of words that are very similar (especially when accounting for leet-speak letters) you are much more likely to have collisions in a hash table. It will also take up significantly more space (although in this instance, space is relatively cheap.) But partially because I just wanted to implement a trie.