Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class MergeSort {
- mergeSort(array, start, end);
- if(start < end);
- midPoint = (end - start) / 2 + start;
- mergeSort(array, start, midPoint);
- mergeSort(array, midPoint + 1, start);
- merge(array, start, midPoint, end);
- }
- public class merge {
- merge(array, start, middle, end);
- i = start;
- j = middle + 1;
- arrayTemp = initArrayOfSize(end - start + 1);
- for (k = 0 until end-start){
- if (i <= middle && (j > end || array[i] <= array[j]));
- arrayTemp[k] = array[i];
- i++;
- }
- else{
- arrayTemp[k] = array[j];
- j++;
- copyArray(arrayTemp, array, start);
- }
- public class mergeArray{
- merge(array);
- merge(array, start, end);
- }
- }
- }
- }
- // Write your code here
- public static void main(String[] args) {
- /*
- * This main method is a stub.
- * It does nothing.
- * Feel free to write your own code to test your implementation.
- * In this case, we have nothing actionable in here, just this comment block, so the JVM should rapidly lose interest and move on to the rest of your code.
- */
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement