From f1b3e645381d9b8ea8197fb1473f115de2ee8f96 Mon Sep 17 00:00:00 2001 From: Paul Jungeblut Date: Sat, 22 Nov 2014 13:03:04 +0100 Subject: adding string chapter --- datastructures/trie.cpp | 25 ------------------------- 1 file changed, 25 deletions(-) delete mode 100644 datastructures/trie.cpp (limited to 'datastructures') diff --git a/datastructures/trie.cpp b/datastructures/trie.cpp deleted file mode 100644 index 9cfcda5..0000000 --- a/datastructures/trie.cpp +++ /dev/null @@ -1,25 +0,0 @@ -//nur für kleinbuchstaben! -struct node { - node *(e)[26]; - int c = 0;//anzahl der wörter die an dem node enden. - node() { for(int i = 0; i < 26; i++) e[i] = NULL; } -}; - -void insert(node *root, string *txt, int s) { - if(s >= txt->length()) root->c++; - else { - int idx = (int)((*txt).at(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) { - if(s >= txt->length()) return root->c; - int idx = (int)((*txt).at(s) - 'a'); - if(root->e[idx] != NULL) { - return contains(root->e[idx], txt, s+1); - } else return 0; -} -- cgit v1.2.3