This functions finds max element and calls recursive merge sort .
static void mergeSort ( int [ ] arr , int n ) { int maxele = Arrays . stream ( arr ) . max ( ) . getAsInt ( ) + 1 ; mergeSortRec ( arr , 0 , n - 1 , maxele ) ; }