From fb6507ce38971858a1b99743851c02b88740144b Mon Sep 17 00:00:00 2001 From: marina <138340846+bt3gl-cryptographer@users.noreply.github.com> Date: Thu, 3 Aug 2023 16:29:43 -0700 Subject: [PATCH] Update README.md --- tries/README.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tries/README.md b/tries/README.md index dbeeec7..6867bae 100644 --- a/tries/README.md +++ b/tries/README.md @@ -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).
+ + +---- + +### comparison with hash tables + +
+ +* 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. + +