package sort;
import java.util.Hashtable;
public class InsertSort extends SortMethod {
public static int RECURSION = 0;
@Override
RECURSION++;
System.
out.
println("I'm an insert sort! " + RECURSION
+ "° Recursion!");
if (pArray.length == 1) {
return pArray;
} else if (pArray.length == 2) {
int swap = 0;
if (pArray[0] > pArray[1]) {
swap = pArray[0];
pArray[0] = pArray[1];
pArray[1] = swap;
}
return pArray;
}
Hashtable
<Integer,
Integer[]> divide
= this.
divide(pArray
);
first = this.sort(first);
second = this.sort(second);
pArray = this.merge(first, second);
return pArray;
}
Hashtable
<Integer,
Integer[]> retval
= new Hashtable
<Integer,
Integer[]>(2
);
for (int i = 0; i < pArray.length; i++) {
if (i == 0) {
first[0] = pArray[0];
} else {
second[sec] = pArray[i];
sec++;
}
}
retval.put(0, first);
retval.put(1, second);
return retval;
}
int first = 0;
int second = 0;
boolean oneEnd = false;
int i = 0;
for (i = 0; i < retval.length && !oneEnd; i++) {
if (pFirst[first] < pSecond[second]) {
retval[i] = pFirst[first];
first++;
} else {
retval[i] = pSecond[second];
second++;
}
oneEnd = first >= pFirst.length || second >= pSecond.length;
}
if (first != 1) {
retval[i] = pFirst[first];
} else {
for (; second < pSecond.length; second++) {
retval[i] = pSecond[second];
i++;
}
}
return retval;
}
}