diff options
| author | Paul Jungeblut <paul.jungeblut@gmail.com> | 2016-10-06 00:14:07 +0200 |
|---|---|---|
| committer | Paul Jungeblut <paul.jungeblut@gmail.com> | 2016-10-06 00:14:07 +0200 |
| commit | 7c97303ec8fc5dfc278198687d8c5154e0cd1baf (patch) | |
| tree | 4ad42ac9f3cafeef0aa7b324b2bc8c62f29fd76c /datastructures/segmentTree.cpp | |
| parent | b585d932530f755e80829bfc5d28d97b5afe1e15 (diff) | |
Adjusting datastructures chapter to new layout.
Diffstat (limited to 'datastructures/segmentTree.cpp')
| -rw-r--r-- | datastructures/segmentTree.cpp | 3 |
1 files changed, 1 insertions, 2 deletions
diff --git a/datastructures/segmentTree.cpp b/datastructures/segmentTree.cpp index cb303d1..c67cd8b 100644 --- a/datastructures/segmentTree.cpp +++ b/datastructures/segmentTree.cpp @@ -6,7 +6,7 @@ int query(int x, int y, int k = 0, int X = 0, int Y = MAX_N - 1) { if (x <= X && Y <= y) return m[k]; if (y < X || Y < x) return -1000000000; // Ein "neutrales" Element. int M = (X + Y) / 2; - return max(query(x, y, 2 * k + 1, X, M), query(x, y, 2 * k + 2, M + 1, Y)); + return max(query(x, y, 2*k+1, X, M), query(x, y, 2*k+2, M+1, Y)); } void update(int i, int v, int k = 0, int X = 0, int Y = MAX_N - 1) { @@ -18,7 +18,6 @@ void update(int i, int v, int k = 0, int X = 0, int Y = MAX_N - 1) { m[k] = max(m[2 * k + 1], m[2 * k + 2]); } -// Einmal vor allen anderen Operationen aufrufen. void init(int k = 0, int X = 0, int Y = MAX_N - 1) { if (X == Y) { m[k] = a[X]; return; } int M = (X + Y) / 2; |
