mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-04-29 20:26:07 -04:00
Update README.md
This commit is contained in:
parent
39262bfbe4
commit
fb6507ce38
@ -73,3 +73,15 @@ class Trie:
|
||||
* if the search succeeds, we need to check if the target word is only a prefix of words in the trie or if it's exactly a word (for example, by adding a boolean flag).
|
||||
|
||||
<br>
|
||||
|
||||
|
||||
----
|
||||
|
||||
### comparison with hash tables
|
||||
|
||||
<br>
|
||||
|
||||
* hash table wins in terms of time complexity, as its insert is usually `O(1)` (worst case `O(log(N))` and trie's are `O(M)` (where `M` is the maximum length of a key).
|
||||
* trie wins in terms of space complexity. both `O(M *N)` in theory, but tries can be much smaller as there will be a lot of words that have similar prefix.
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user