An array is sorted (in ascending order) if each element of the array is less than or equal to the next element.

An array  is sorted (in ascending order) if each element of the array is less than  or equal to the next element.

LANGUAGE: JAVA

CHALLENGE:

An array is sorted (in ascending order) if each element of the array is less than or equal to the next element.
• An array of size 0 or 1 is sorted
• Compare the first two elements of the array ; if they are out of order, the array is not sorted; otherwise, check the if the rest of the array is sorted.
Write a boolean -valued method named isSorted that accepts an integer array , and the number of elements in the array and returns whether the array is sorted.

This content requires that you purchase additional access. The price is $2.99 or free for our Make Life Easier and 30 Days – Not Recurring members.

Purchase this Content ($2.99) Choose a Membership Level