summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Jungeblut <s_jungeb@i08pc55.atis-stud.uni-karlsruhe.de>2014-11-24 15:32:56 +0100
committerPaul Jungeblut <s_jungeb@i08pc55.atis-stud.uni-karlsruhe.de>2014-11-24 15:32:56 +0100
commit9132c2f869e166f871027a99d1746f712397ce08 (patch)
treef51aaed4aab3d8cb2bbb1ac11cb7d474f7ac15ed
parentcb1ed059fe6d3518436d32160e51c84d4517ea26 (diff)
small fixes
-rw-r--r--datastructures/unionFind.cpp2
-rw-r--r--graph/floydWarshall.cpp2
-rw-r--r--math/factor.cpp34
-rw-r--r--math/math.tex6
-rw-r--r--math/primeSieve.cpp15
-rw-r--r--tcr.pdfbin331401 -> 330156 bytes
-rw-r--r--toDo.txt2
7 files changed, 14 insertions, 47 deletions
diff --git a/datastructures/unionFind.cpp b/datastructures/unionFind.cpp
index c946ef6..1ee532c 100644
--- a/datastructures/unionFind.cpp
+++ b/datastructures/unionFind.cpp
@@ -1,4 +1,4 @@
-vector<int> parent, rank2; //manche compiler verbieten Variable mit Namen rank
+vector<int> parent, rank2; //manche Compiler verbieten Variable mit Namen rank
int findSet(int n) { //Pfadkompression
if (parent[n] != n) parent[n] = findSet(parent[n]);
diff --git a/graph/floydWarshall.cpp b/graph/floydWarshall.cpp
index ee56441..f5c950d 100644
--- a/graph/floydWarshall.cpp
+++ b/graph/floydWarshall.cpp
@@ -1,4 +1,4 @@
-//initialize adjmat, adjmat[i][i] = 0, adjmat[i][j] = INF if no edge is between i and j
+//initialize adjmat, adjmat[i][i] = 0, adjmat[i][j] = INF if no edge is between i and j, length otherwise
for (k = 0; k < MAX_V; k++) {
for (i = 0; i < MAX_V; i++) {
for (j = 0; j < MAX_V; j++) {
diff --git a/math/factor.cpp b/math/factor.cpp
index 43aeae3..0e5d7d8 100644
--- a/math/factor.cpp
+++ b/math/factor.cpp
@@ -1,27 +1,5 @@
-#include <iostream>
-#include <vector>
-
-using namespace std;
-
-typedef unsigned long long ll;
-
const ll PRIME_SIZE = 10000000;
-vector<int> primes;
-
-//Call before calculating anything
-void primeSieve() {
- vector<int> isPrime(PRIME_SIZE,true);
- for(ll i = 2; i < PRIME_SIZE; i+=2) {
- if(isPrime[i]) {
- primes.push_back(i);
- if(i*i <= PRIME_SIZE) {
- for(ll j = i; i*j < PRIME_SIZE; j+=2) isPrime[i*j] = false;
- }
- }
- if(i == 2)
- i--;
- }
-}
+vector<int> primes; //call primeSieve(PRIME_SIZE); before
//Factorize the number n
vector<int> factorize(ll n) {
@@ -33,13 +11,9 @@ vector<int> factorize(ll n) {
num /= primes[pos];
factor.push_back(primes[pos]);
}
- else
- pos++;
- if(primes[pos]*primes[pos] > n)
- break;
+ else pos++;
+ if(primes[pos]*primes[pos] > n) break;
}
- if(num != 1)
- factor.push_back(num);
+ if(num != 1) factor.push_back(num);
return factor;
-
}
diff --git a/math/math.tex b/math/math.tex
index ca67f0e..feb89ff 100644
--- a/math/math.tex
+++ b/math/math.tex
@@ -17,6 +17,9 @@ Sei $0 \leq x < n$. Definiere $d := gcd(x, n)$.
\end{description}
\lstinputlisting{math/multInv.cpp}
+\subsection{Primzahlsieb von Eratosthenes}
+\lstinputlisting{math/primeSieve.cpp}
+
\subsubsection{Faktorisierung}
\lstinputlisting{math/factor.cpp}
@@ -29,9 +32,6 @@ Sei $0 \leq x < n$. Definiere $d := gcd(x, n)$.
\subsection{Binomialkoeffizienten}
\lstinputlisting{math/binomial.cpp}
-\subsection{Primzahlsieb von Eratosthenes}
-\lstinputlisting{math/primeSieve.cpp}
-
\subsection{Satz von \textsc{Sprague-Grundy}}
Weise jedem Zustand $X$ wie folgt eine \textsc{Grundy}-Zahl $g\left(X\right)$ zu:
\[
diff --git a/math/primeSieve.cpp b/math/primeSieve.cpp
index 4c82bbe..db96e5b 100644
--- a/math/primeSieve.cpp
+++ b/math/primeSieve.cpp
@@ -1,12 +1,5 @@
-#include <iostream>
-#include <vector>
-
-using namespace std;
-
-typedef unsigned long long ll;
-
-vector<int> primeSieve(ll n) {
- vector<int> primes;
+vector<int> primes;
+void primeSieve(ll n) { //berechnet die Primzahlen kleiner n
vector<int> isPrime(n,true);
for(ll i = 2; i < n; i+=2) {
if(isPrime[i]) {
@@ -15,8 +8,6 @@ vector<int> primeSieve(ll n) {
for(ll j = i; i*j < n; j+=2) isPrime[i*j] = false;
}
}
- if(i == 2)
- i--;
+ if(i == 2) i--;
}
- return primes;
}
diff --git a/tcr.pdf b/tcr.pdf
index 8194664..a81bb35 100644
--- a/tcr.pdf
+++ b/tcr.pdf
Binary files differ
diff --git a/toDo.txt b/toDo.txt
index d3b1b4a..da52b51 100644
--- a/toDo.txt
+++ b/toDo.txt
@@ -7,3 +7,5 @@
- linear time sorting
- roman numerals
- towers of hanoi
+- Schnitteigenschaft/Kreiseigenschaft
+- Zusammenhang Max Flow, Max Independent Set, etc. \ No newline at end of file