New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Reduce memory usage of Trie maybe #21
Comments
Originally, Tag was added to reduce memory use 😛. This field's first use is to describe TrieNode type based on the number of child nodes:
For example, a Trie containing words "bat" and "bacon" would have this structure:
I'd recommend looking into radix trees for further memory savings. You might lose some insertion speed, but you can save lots of nodes. Edit: Fixed a couple things in the diagram since original posting |
First off: Great explanation and diagram! I did a rather poor job of explaining what I was attempting to do. So for example, object can be cast to either null, the direct payload, a single node, or an object[37]
I don't know if this is actually feasible though. Last time I tried to implement it, ended up running into issues and gave up. |
The only problem I see with your approach is handling values attached to non-leaf nodes. For example, consider the case where we add "ba" and "batman" to the Trie. Now |
can probably get rid of Tag and look directly at Children and Payload. not a high priority though.
The text was updated successfully, but these errors were encountered: