From db340a89a3080e1741a365dc0ffd9d8efc85bd6a Mon Sep 17 00:00:00 2001 From: finnm Date: Tue, 10 Dec 2024 17:11:58 +0100 Subject: [PATCH] Fixed order of merges of the remaining stack --- .../java/de/uni_marburg/powersort/FinnSort/FinnSort.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/de/uni_marburg/powersort/FinnSort/FinnSort.java b/app/src/main/java/de/uni_marburg/powersort/FinnSort/FinnSort.java index bd84f69..ac9a591 100644 --- a/app/src/main/java/de/uni_marburg/powersort/FinnSort/FinnSort.java +++ b/app/src/main/java/de/uni_marburg/powersort/FinnSort/FinnSort.java @@ -33,7 +33,7 @@ public class FinnSort { i = j; } while (runs.size() >= 2) { - basicMerge(a, runs.removeFirst(), runs.removeFirst()); + basicMerge(a, runs.removeLast(), runs.removeLast()); } } @@ -70,10 +70,11 @@ public class FinnSort { } int n_1 = run1.end - run1.start; int n_2 = run2.end - run2.start; - double a = ((double) run1.start + 0.5 * n_1 - 1) / n; - double b = ((double) run2.start + 0.5 * n_2 - 1) / n; + double a = ((double) run1.start + 0.5d * n_1 - 1d) / n; + double b = ((double) run2.start + 0.5d * n_2 - 1d) / n; int l = 0; while ((int) (a * pow(2, l)) == (int) (b * pow(2 ,l))) { + l++; } return l;