Question
JAVA a) This method should return true if and only if every element in the input array is in ascending order, meaning that none of
JAVA
a) This method should return true if and only if every element in the input array is in ascending order, meaning that none of the values in the array are smaller than the previous element, and false otherwise. For example, the array {1, 2, 5, 5, 6, 7, 8, 8, 8} would be in order. An empty array is considered in order as well.
public static boolean order(int[] a)
b)This method will return the smallest value found in the array. For example, for the array {4, 2, 3, 1, 5, 1}, the value 1 will be returned. If the array is empty, then the built-in constant Integer.MAX_VALUE may be returned.
public static int small(int[] a)
c)This method will return the smallest value found in the array which is larger than the input n. For example, for the input n = 2 and the array {4, 2, 3, 1, 5, 1}, the value 3 will be returned. If no such value exists, then the method will return the value n.
public static int smalln(int n, int[] a)
d)Return the total number of distinct values contained in the input array. For example, the array {2, 2, 5, 1, 7, 4, 7} has 5 distinct values (the numbers 1, 2, 4, 5, and 7). Each of those five values appear at least once (the numbers 2 and 7 appear twice each, but they are only counted once).
public static int diff(int[] a)
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started