Question: Write a method public static boolean is Sorted (int[] nums, boolean ascending) that returns true if the array passed to the method is sorted
Write a method public static boolean is Sorted (int[] nums, boolean ascending) that returns true if the array passed to the method is sorted and returns false if it is not sorted or empty. The parameter named ascending indicates what kind of order we are checking for: either ascending (when ascending is set to true) or descending (when ascending is set to false). Requirement: Your algorithm must be linear, meaning you pass through the elements of the array once.
Step by Step Solution
3.43 Rating (159 Votes )
There are 3 Steps involved in it
Certainly Heres a Java implementation for the isSorted method based on your requirements public clas... View full answer
Get step-by-step solutions from verified subject matter experts
