Mergesort
algorithm is to divide an array in half, sort each half, and then usemerge()
method to merge the two halves into a single sorted array. merge()
method that takes in merge({2,5,7,8,9},{9}) -> {2,5,7,8,9,9}
merge()({7,8},{1,2}) -> {1,2,7,8}
merge()({2},{}) -> {2}
{} -> [Empty] Array
A
and B
creates a third array C
that contains all thepublic static int[] merge(int[] arrLeft, int[] arrRight){ }
C
Java
Python