mirror of
https://github.com/autistic-symposium/master-algorithms-py.git
synced 2025-05-02 06:46:18 -04:00
Update README.md
This commit is contained in:
parent
39262bfbe4
commit
fb6507ce38
1 changed files with 12 additions and 0 deletions
|
@ -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…
Add table
Add a link
Reference in a new issue