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.
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.
For further actions, you may consider blocking this person and/or reporting abuse
We're a place where coders share, stay up-to-date and grow their careers.
Why a Trie instead of the native
setdata type?setwill 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.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.