5 ms·
I can't figure out how this works. Shouldn't insert return a reference to the new trie?
by dmurray 5y ago
I can't figure out how this works. Shouldn't insert return a reference to the new trie?
- juki 5y agoNo, it mutates the input trie. If you call `insert(trie, "foo")` with an empty trie, it will be modified to look like {'f': {'o': {'o': {END: True}}}} I don't think this implementation is efficient enough to ever be worth using in a real program, though.
- masklinn 5y agoIt probably works well enough for relatively simple problems, but the overhead of the dicts is definitely going to kill you memory-wise.