java - merge sorting of 2 unsorted arrays -


is following implemetation correct merge sort?

public int [] merge_srt(int [] ary){         if(ary.length==1)             return ary;         int mid = (int)ary.length/2;         int a1[] =  merge_srt(arrays.copyofrange(ary, 0, mid));         int a2[] = merge_srt(arrays.copyofrange(ary, mid+1,  ary.length-1));         return mergea(a1,a2);      }      public  int[]  mergea(int[] a1,int [] a2){          // merge 2 array , reurn 1 sorted array      } 

change

    if (ary.length == 1)                    return ary;  

to

    if (ary.length <= 1)                    return ary;  

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -