summaryrefslogtreecommitdiff
path: root/string/trie.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'string/trie.cpp')
-rw-r--r--string/trie.cpp6
1 files changed, 2 insertions, 4 deletions
diff --git a/string/trie.cpp b/string/trie.cpp
index 5ee7a87..33889dc 100644
--- a/string/trie.cpp
+++ b/string/trie.cpp
@@ -1,6 +1,5 @@
-// Implementierung für Kleinbuchstaben.
struct node {
- node *(e)[26];
+ node *(e)[26]; // Implementierung für Kleinbuchstaben.
int c = 0; // Anzahl der Wörter, die an diesem node enden.
node() { for(int i = 0; i < 26; i++) e[i] = NULL; }
};
@@ -11,8 +10,7 @@ void insert(node *root, string &txt, int s) { // Laufzeit: O(|txt|)
int idx = (int)(txt[s] - 'a');
if(root->e[idx] == NULL) root->e[idx] = new node();
insert(root->e[idx], txt, s+1);
- }
-}
+}}
int contains(node *root, string &txt, int s) { // Laufzeit: O(|txt|)
if(s == txt.size()) return root->c;