summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--convenience/convenience.tex4
-rw-r--r--java/java.tex28
-rw-r--r--string/levenshtein.cpp3
-rw-r--r--string/trie.cpp12
-rw-r--r--tcr.pdfbin251573 -> 251933 bytes
5 files changed, 26 insertions, 21 deletions
diff --git a/convenience/convenience.tex b/convenience/convenience.tex
index 84dd4e1..23ac7f2 100644
--- a/convenience/convenience.tex
+++ b/convenience/convenience.tex
@@ -19,4 +19,8 @@ set<point2, decltype(comp)> set1(comp);
// PI
#define PI (2*acos(0))
+
+// STL-Debugging, Compiler flags.
+-D_GLIBCXX_DEBUG
+#define _GLIBCXX_DEBUG
\end{lstlisting}
diff --git a/java/java.tex b/java/java.tex
index d9c3a75..f52e733 100644
--- a/java/java.tex
+++ b/java/java.tex
@@ -7,43 +7,43 @@
\item Compilen: \lstinline{javac main.java}
\item Ausführen: \lstinline{java main < sample.in}
\item Eingabe:
+\lstinline{Scanner} ist sehr langsam. Bei großen Eingaben muss ein Buffered Reader verwendet werden.
\begin{lstlisting}
-Scanner in = new Scanner(System.in); //java.util.Scanner
-String line = in.nextLine(); //reads the next line of the input
-int num = in.nextInt(); //reads the next token of the input as an int
-double num2 = in.nextDouble(); //reads the next token of the input as a double
+Scanner in = new Scanner(System.in); // java.util.Scanner
+String line = in.nextLine(); // Liest die nächste Zeile.
+int num = in.nextInt(); // Liest das nächste Token als int.
+double num2 = in.nextDouble(); // Liest das nächste Token als double.
\end{lstlisting}
\item Ausgabe:
\begin{lstlisting}
-//Ausgabe in StringBuilder schreiben und am Ende alles auf einmal ausgeben -> viel schneller
-StringBuilder sb = new StringBuilder(); //java.lang.StringBuilder
+// Ausgabe in StringBuilder schreiben und am Ende alles auf einmal ausgeben. -> Viel schneller.
+StringBuilder sb = new StringBuilder(); // java.lang.StringBuilder
sb.append("Hallo Welt");
System.out.print(sb.toString());
\end{lstlisting}
\end{itemize}
\subsection{BigInteger}
-Hier ein kleiner überblick über die Methoden der Klasse BigInteger:
\begin{lstlisting}
-//Returns this +,*,/,- val
+// Berechnet this +,*,/,- val.
BigInteger add(BigInteger val), multiply(BigInteger val), divide(BigInteger val), substract(BigInteger val)
-//Returns this^e
+// Berechnet this^e.
BigInteger pow(BigInteger e)
-//Bit-Operations
+// Bit-Operationen.
BigInteger and(BigInteger val), or(BigInteger val), xor(BigInteger val), not(), shiftLeft(int n), shiftRight(int n)
-//Returns the greatest common divisor of abs(this) and abs(val)
+// Berechnet den ggT von abs(this) und abs(val).
BigInteger gcd(BigInteger val)
-//Returns this mod m, this^-1 mod m, this^e mod m
+// Berechnet this mod m, this^-1 mod m, this^e mod m.
BigInteger mod(BigInteger m), modInverse(BigInteger m), modPow(BigInteger e, BigInteger m)
-//Returns the next number that is greater than this and that is probably a prime.
+// Berechnet die nächste Zahl, die größer und wahrscheinlich prim ist.
BigInteger nextProbablePrime()
-//Converting BigInteger. Attention: If the BigInteger is to big the lowest bits were choosen which fits into the converted data-type.
+// Berechnet int/long/float/double-Wert. Ist die Zahl zu großen werden die niedrigsten Bits konvertiert.
int intValue(), long longValue(), float floatValue(), double doubleValue()
\end{lstlisting}
\lstset{language=C++} \ No newline at end of file
diff --git a/string/levenshtein.cpp b/string/levenshtein.cpp
index d1980f8..f0df66b 100644
--- a/string/levenshtein.cpp
+++ b/string/levenshtein.cpp
@@ -1,3 +1,4 @@
+// Laufzeit: O(nm), Speicher: O(m), n = #s1, m = #s2
int levenshtein(string& s1, string& s2) {
int len1 = s1.size(), len2 = s2.size();
vector<int> col(len2 + 1), prevCol(len2 + 1);
@@ -9,4 +10,4 @@ int levenshtein(string& s1, string& s2) {
col.swap(prevCol);
}
return prevCol[len2];
-} \ No newline at end of file
+}
diff --git a/string/trie.cpp b/string/trie.cpp
index f4b979c..24a21b2 100644
--- a/string/trie.cpp
+++ b/string/trie.cpp
@@ -1,14 +1,14 @@
-//nur fuer kleinbuchstaben!
+// Implementierung für Kleinbuchstaben.
struct node {
node *(e)[26];
- int c = 0;//anzahl der woerter die an dem node enden.
+ int c = 0; // Anzahl der Wörter, die an diesem 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++;
+ if(s == txt->length()) root->c++;
else {
- int idx = (int)((*txt).at(s) - 'a');
+ int idx = (int)(*txt[s] - 'a');
if(root->e[idx] == NULL) {
root->e[idx] = new node();
}
@@ -17,8 +17,8 @@ void insert(node *root, string *txt, int s) {
}
int contains(node *root, string *txt, int s) {
- if(s >= txt->length()) return root->c;
- int idx = (int)((*txt).at(s) - 'a');
+ if(s == txt->length()) return root->c;
+ int idx = (int)(*txt[s] - 'a');
if(root->e[idx] != NULL) {
return contains(root->e[idx], txt, s+1);
} else return 0;
diff --git a/tcr.pdf b/tcr.pdf
index 1009c88..12d0993 100644
--- a/tcr.pdf
+++ b/tcr.pdf
Binary files differ