Answer:
Check the explanation
Explanation:
Algorithm for determining if the array passed as argument is in descending order or not.
1. Start
2. A = {1, 2, 3, 4};
3. Call function by passing array and it's size.
isDescending(A, A.length);
4. Loop from 1 to size - 1 (inclusive)
5. check if element at (i-1)th index is greater than element at (i)th index or not
6. if at any point the above expression is executed to true value then return false
7. if the above if statement is not executed then loop will terminate it self
8. Now return true.
// Java Implementation:
public static boolean isDescending(int[] arr, int size) {
for (int i = 1; i < size; i++) {
if (arr[i-1] > arr[i]) {
return false;
}
}
return true;
}