From 77475749f1f7957edededcb5cb70f770e79cfaae Mon Sep 17 00:00:00 2001
From: Lawrence Chung <chungl1@mcmaster.ca>
Date: Mon, 26 Feb 2018 03:30:05 -0500
Subject: [PATCH] Questions about conditional and GeneralCompare issues

---
 src/sort/mergeSort.java | 24 ++++++++++++------------
 1 file changed, 12 insertions(+), 12 deletions(-)

diff --git a/src/sort/mergeSort.java b/src/sort/mergeSort.java
index 04c3573..eef5d62 100644
--- a/src/sort/mergeSort.java
+++ b/src/sort/mergeSort.java
@@ -10,23 +10,23 @@ public class mergeSort implements GeneralCompare{
 		
 		if(n <= 1)
 			return;
-		int mid = n/2;
-		merge(gc, mid);
-		merge(gc, mid+1);
+		int j = (n/2) + 1, i = 0;
+		merge(gc, j);
+		merge(gc, j+1);
 		
-		for(int i = 1; i <= n; i++){
+		for(int k = 1; k <= n; k++){
 			aux[i] = gc[i];
 		}
 		
-		for(int i = 1; i <= n; i++){
-			if(i > mid) //Should these not be a[i] and a[mid]?
-				gc[i] = aux[mid++];
-			else if(mid+1 > n) //^
-				gc[i] = aux[2];
-			else if(compare(aux[mid+1],aux[1]) < 0)// ?
-				gc[i] = aux[i]; //fill statement (incorrect)
+		for(int k = 1; k <= n; k++){
+			if(i > j-1) //Should these not be a[i] and a[mid]?
+				gc[k] = aux[j++];
+			else if(j > n) //^
+				gc[k] = aux[2];
+			else if(compare(aux[j+1],aux[1]) < 0)// ?
+				gc[k] = aux[j++]; //fill statement (incorrect)
 			else 
-				gc[i] = aux[2];
+				gc[k] = aux[i++];
 		}
 		
 	}
-- 
GitLab