-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathExternalSorting.java
More file actions
32 lines (26 loc) · 1022 Bytes
/
ExternalSorting.java
File metadata and controls
32 lines (26 loc) · 1022 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
public class ExternalSorting {
public Integer[] sort(Integer[] array) {
int subArraylength = 4;
int i = 0;
int count = 0;
Integer[][] subArrays = new Integer[3][subArrayLength];
while (i < array.length) {
int numOfElements = (array.length - i) > subArrayLength? subArrayLength: array.length - i;
subArrays[count++] = sortSubArray(array, i, numOfElements);
i = i + subArrayLength;
}
}
Integer[] sortSubArray(Integer[] array, int start, int size) {
return mergeSort(array, start, size)
}
Integer[] mergeSort(Integer[] array, int start, int size) {
}
public static void main(String[] args) {
Integer[] array = new Integer[] {3, 2, 1, 4, 6, 5, 9, 8, 7, 10};
ExternalSorting es = new ExternalSorting();
Integer[] sortedArray = es.sort(array);
for (int i = 0; i < array.length; i++)
System.out.print(array[i]);
System.out.println();
}
}