java – Check if the given matrix is ​​ordered by dividing and conquer

It seems that you are doing mainly good. You have problems with arrays of zero length and length 1, but you should be able to fix them quite quickly.

You may be doing more work than necessary. If a matrix is ​​not ordered, you may find left side is false, but unconditionally you are going to determine the value of Right part Anyway, even though it does not matter. The simplest way to avoid that is to combine those recursive calls and the && operation. That is to say:

return isSorted (arr, start, middle) && isSorted (arr, middle, end);

Finally, if the matrix contains duplicates, can it still be considered ordered? Came back false for [1, 2, 2, 3].