From 6357dd605bc2634dfb6331c1af259e9e00d48119 Mon Sep 17 00:00:00 2001 From: incredibleLeitman Date: Sun, 18 Oct 2020 12:28:33 +0200 Subject: [PATCH] removed some comments and newlines --- MedianOfMedians.h | 5 ++--- main.cpp | 3 --- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/MedianOfMedians.h b/MedianOfMedians.h index 20073b7..b483b8d 100644 --- a/MedianOfMedians.h +++ b/MedianOfMedians.h @@ -7,6 +7,7 @@ uint32_t partition(std::vector &v, uint32_t left, uint32_t right, uint // Return the index of an element which is close to (but likely not exactly) the median. uint32_t findMedianOfMedians(std::vector &v, uint32_t left, uint32_t right, uint32_t n) { + while (true) { if (left == right) { return left; @@ -26,8 +27,8 @@ uint32_t findMedianOfMedians(std::vector &v, uint32_t left, uint32_t r } uint32_t partition(std::vector &v, uint32_t left, uint32_t right, uint32_t pivotIndex, uint32_t n) { + uint32_t pivotValue = v[pivotIndex]; - swap(&v[pivotIndex], &v[right]); uint32_t storeIndex = left; @@ -72,10 +73,8 @@ uint32_t partition5(std::vector &v, uint32_t left, uint32_t right) { swap(&v[j - 1], &v[j]); j = j - 1; } - i = i + 1; } - return (left + right) / 2; } diff --git a/main.cpp b/main.cpp index 8783b27..b62165e 100644 --- a/main.cpp +++ b/main.cpp @@ -9,9 +9,6 @@ #include "RandomizedSelect.h" #include "Wirth.h" -// TODO: -// - combine partition function -// - fix Median of Medians int main(int argc, char** argv) {