Skip to content
Snippets Groups Projects
Commit 77475749 authored by Lawrence Chung's avatar Lawrence Chung
Browse files

Questions about conditional and GeneralCompare issues

parent 7e78ae68
No related branches found
No related tags found
No related merge requests found
......@@ -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++];
}
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment