Adapt Wirth to data type change
This commit is contained in:
parent
be69fb41be
commit
90347e06a3
12
Wirth.h
12
Wirth.h
@ -2,15 +2,15 @@
|
|||||||
|
|
||||||
// http://ndevilla.free.fr/median/median/index.html
|
// http://ndevilla.free.fr/median/median/index.html
|
||||||
|
|
||||||
size_t getWirthKthSmallest(std::vector<size_t> a, size_t k)
|
uint32_t getWirthKthSmallest(std::vector<uint32_t> a, uint32_t k)
|
||||||
{
|
{
|
||||||
size_t l = 0;
|
uint32_t l = 0;
|
||||||
size_t m = a.size() - 1;
|
uint32_t m = a.size() - 1;
|
||||||
|
|
||||||
while (l < m) {
|
while (l < m) {
|
||||||
size_t x = a[k];
|
uint32_t x = a[k];
|
||||||
size_t i = l;
|
uint32_t i = l;
|
||||||
size_t j = m;
|
uint32_t j = m;
|
||||||
|
|
||||||
do {
|
do {
|
||||||
while (a[i] < x) i++;
|
while (a[i] < x) i++;
|
||||||
|
2
main.cpp
2
main.cpp
@ -78,7 +78,7 @@ int main(int argc, char** argv)
|
|||||||
Timing::getInstance()->stopRecord("array median of medians");*/
|
Timing::getInstance()->stopRecord("array median of medians");*/
|
||||||
|
|
||||||
// noch ein ein weiterer Median - Algorithmus weil wir so cool sind
|
// noch ein ein weiterer Median - Algorithmus weil wir so cool sind
|
||||||
std::vector<size_t> numbers_wirth(numbers); // Copy because wirth works in-place
|
std::vector<uint32_t> numbers_wirth(numbers); // Copy because wirth works in-place
|
||||||
Timing::getInstance()->startRecord("wirth");
|
Timing::getInstance()->startRecord("wirth");
|
||||||
std::cout << "wirth kth element: " << getWirthKthSmallest(numbers_wirth, idxMed) << std::endl;
|
std::cout << "wirth kth element: " << getWirthKthSmallest(numbers_wirth, idxMed) << std::endl;
|
||||||
Timing::getInstance()->stopRecord("wirth");
|
Timing::getInstance()->stopRecord("wirth");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user