added code to count number of writes used

This commit is contained in:
2020-06-02 13:26:54 -05:00
parent 826f4ebe0e
commit 2e8fa28a5a

View File

@@ -21,11 +21,13 @@ public class CountingSorter extends Sorter{
int[] countArray = new int[max-min+1];
for(int e: numbers){
countArray[e-min]++;
wrtiesUsed++;
}
int index=0;
for(int i=0;i<countArray.length;i++){
while(countArray[i]!=0){
numbers[index]=i+min;
wrtiesUsed++;
index++;
countArray[i]--;
}