Advertisement
jdshort410230

So far

Jan 27th, 2020
113
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1. public class MergeSort {
  2.     mergeSort(array, start, end);
  3.     if(start < end);
  4.     midPoint = (end - start) / 2 + start;
  5.     mergeSort(array, start, midPoint);
  6.     mergeSort(array, midPoint + 1, start);
  7.     merge(array, start, midPoint, end);
  8. }
  9. public class merge {
  10.     merge(array, start, middle, end);
  11.     i = start;
  12.     j = middle + 1;
  13.     arrayTemp = initArrayOfSize(end - start + 1);
  14.     for (k = 0 until end-start){
  15.         if (i <= middle && (j > end || array[i] <= array[j]));
  16.         arrayTemp[k] = array[i];
  17.         i++;
  18.     }
  19.     else{
  20.         arrayTemp[k] = array[j];
  21.         j++;
  22.         copyArray(arrayTemp, array, start);
  23.     }
  24.     public class mergeArray{
  25.         merge(array);
  26.         merge(array, start, end);
  27.     }
  28.     }
  29.     }
  30. }
  31.     // Write your code here
  32.  
  33.     public static void main(String[] args) {
  34.         /*  
  35.         * This main method is a stub.
  36.         * It does nothing.
  37.         * Feel free to write your own code to test your implementation.
  38.         * 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.
  39.         */
  40.     }
  41.  
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement