I want to write a method (returning a boolean value) named itisSorted that takes two arguments;
-
data: an integer array n: the number of elements in the array
true if (and only if) the data array is sorted.
public boolean itisSorted(int [] data, int n)
{
if(data.length ==0 || data.length==1)
return true;
else if (data[n] > data[n-1]) //here i compare the first two elements
return false;
else //here is where i put the recursive call to check if
// the rest of the array is sorted, but I am having difficulties with the
// part of the code
}