diff options
| author | Paul Jungeblut <s_jungeb@i08pc57.atis-stud.uni-karlsruhe.de> | 2014-11-22 13:03:04 +0100 |
|---|---|---|
| committer | Paul Jungeblut <s_jungeb@i08pc57.atis-stud.uni-karlsruhe.de> | 2014-11-22 13:03:04 +0100 |
| commit | f1b3e645381d9b8ea8197fb1473f115de2ee8f96 (patch) | |
| tree | 3bd28497e0dcbb025a9a740fbf441932ea927fd2 | |
| parent | 9fe234e7181b1cad9652655e674e7f9f821814b7 (diff) | |
adding string chapter
| -rw-r--r-- | string/LCSubstring.cpp (renamed from sonstiges/LCSub.cpp) | 0 | ||||
| -rw-r--r-- | string/string.tex | 13 | ||||
| -rw-r--r-- | string/suffixArray.cpp (renamed from sonstiges/SufixArray.cpp) | 6 | ||||
| -rw-r--r-- | string/trie.cpp (renamed from datastructures/trie.cpp) | 4 | ||||
| -rw-r--r-- | tcr.pdf | bin | 297317 -> 306669 bytes | |||
| -rw-r--r-- | tcr.tex | 1 |
6 files changed, 19 insertions, 5 deletions
diff --git a/sonstiges/LCSub.cpp b/string/LCSubstring.cpp index 69d636f..69d636f 100644 --- a/sonstiges/LCSub.cpp +++ b/string/LCSubstring.cpp diff --git a/string/string.tex b/string/string.tex new file mode 100644 index 0000000..1335c4a --- /dev/null +++ b/string/string.tex @@ -0,0 +1,13 @@ +\section{Strings} + +\subsection{\textsc{Knuth-Morris-Pratt}-Algorithmus} +\lstinputlisting{string/kmp.cpp} + +\subsection{Trie} +\lstinputlisting{string/trie.cpp} + +\subsection{Suffix-Array} +\lstinputlisting{string/suffixArray.cpp} + +\subsection{Longest Common Substring} +\lstinputlisting{string/LCSubstring.cpp} diff --git a/sonstiges/SufixArray.cpp b/string/suffixArray.cpp index bb742f6..2b2a87b 100644 --- a/sonstiges/SufixArray.cpp +++ b/string/suffixArray.cpp @@ -1,10 +1,10 @@ //longest common substring in one string (overlapping not excluded) -//contains suffix array:--------------------------------------------------------------------------------------------------------- +//contains suffix array:-------------------------------------------------------------------- int cmp(string &s,vector<vector<int>> &v, vector<int> &a, int i, int vi, int u, int l) { int vi2 = (vi + 1) % 2, u2 = u + i / 2, l2 = l + i / 2; if(i == 1) return s[u] - s[l]; else if (v[vi2][u] != v[vi2][l]) return (v[vi2][u] - v[vi2][l]); - else { //beide größer tifft nicht mehr ein, da ansonsten vorher schon unterschied in länge + else { //beide groesser tifft nicht mehr ein, da ansonsten vorher schon unterschied in Laenge if(u2 >= s.length()) return -1; else if(l2 >= s.length()) return 1; else return v[vi2][u2] - v[vi2][l2]; @@ -24,7 +24,7 @@ string lcsub(string s) { v[vi][a[0]] = 0; for(int z = 1; z < a.size(); z++) v[vi][a[z]] = v[vi][a[z-1]] + (cmp(s, v, a, i, vi, a[z], a[z-1]) == 0 ? 0 : 1); } -//------------------------------------------------------------------------------------------------------------------------------- +//------------------------------------------------------------------------------------------- int r = 0, m=0, c=0; for(int i = 0; i < a.size() - 1; i++) { c = 0; diff --git a/datastructures/trie.cpp b/string/trie.cpp index 9cfcda5..f4b979c 100644 --- a/datastructures/trie.cpp +++ b/string/trie.cpp @@ -1,7 +1,7 @@ -//nur für kleinbuchstaben! +//nur fuer kleinbuchstaben! struct node { node *(e)[26]; - int c = 0;//anzahl der wörter die an dem node enden. + int c = 0;//anzahl der woerter die an dem node enden. node() { for(int i = 0; i < 26; i++) e[i] = NULL; } }; @@ -56,6 +56,7 @@ \input{graph/graph} \input{geometry/geometry} \input{math/math} +\input{string/string} \input{sonstiges/sonstiges} \end{document}
\ No newline at end of file |
