I need to check if array was sorted strictly descendant. I wrote following code
public boolean isSortedDescendant(int [] array){
if ((array.length == 0) || (array.length == 1)) {
return true;
} else {
for(int i = 0; i < array.length - 1; i++){
if (array[i] > array[i + 1]) {
return true;
}
}
return false;
}
}
But it not working correctly. for
int[] array2 = {3, 2, 2};
at least. I spend a lot of time for different approaches, but without any luck.
i- how do you know the entire array is correct by only checking the first pair?