Skip to content

Commit 7c3b21d

Browse files
author
Hamid Gasmi
committed
#153 Trie description updated
1 parent c179c64 commit 7c3b21d

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

README.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3179,15 +3179,21 @@
31793179
- Runtime: **O(|*Patterns*|)**: the total length of all Texts
31803180
- Space Complexity: (Edges # = **O(|*Patterns*|)**):
31813181
- It takes lot of space: E.g, for human genome, the total length |*Text*| is 10^12 => Space?
3182+
- It could be implemented with a **dictionary of dictionaries**:
3183+
- The key of the external dictionary is the node ID (integer)
3184+
- The internal dictionary contains all the trie edges outgoing from the corresponding node
3185+
- The internal dictionary keys are the letters on those edges
3186+
- The internal dictionary values are the node IDs to which these edges lead
31823187
- E.g., the string texts below could be stored in a Trie:
31833188
- aba, aa, baa
3184-
Root
3185-
/ \
3186-
a b
3187-
/ \ \
3188-
b a a
3189-
/
3190-
a
3189+
0 Trie = { 0: { a:1, b:5 }
3190+
a/ \b 1: { b:2, a:4}
3191+
1 5 2: { a:3 }
3192+
b/ \a \a 3: { }
3193+
2 4 6 4: { }
3194+
a/ 5: { a:6 }
3195+
3 5: { }
3196+
}
31913197
- Multiple Pattern Matching:
31923198
- For simplicity, we assume that no pattern is a substring of another pattern
31933199
- TrieMatching(Text, Trie):
@@ -3210,6 +3216,11 @@
32103216
- Runtime of brute force approach: **O(|*Text*| * |*Patterns*|)**
32113217
- Related Problems:
32123218
- [Construct a Trie from a Collection of Patterns](https://github.com/hamidgasmi/training.computerscience.algorithms-datastructures/issues/154)
3219+
- [Multiple Pattern Matching](https://github.com/hamidgasmi/training.computerscience.algorithms-datastructures/issues/155)
3220+
- [Generalized Multiple Pattern Matching](https://github.com/hamidgasmi/training.computerscience.algorithms-datastructures/issues/156)
3221+
- [Implement an autocomplete feature]():
3222+
- Tries are a common way of storing a dictionary of words and are used, e.g., for implementing an autocomplete feature in text editors
3223+
- E.g., Code editors, and web search engines like Google or Yandex
32133224
- For more details:
32143225
- UC San Diego Course:[Tries](https://github.com/hamidgasmi/training.computerscience.algorithms-datastructures/blob/master/5-string-processing-and-pattern-matching-algorithms/1-suffix-trees/01_suffix_trees.pdf)
32153226

0 commit comments

Comments
 (0)