Question: The minimum difference of a character array is defined as the minimum value of the difference between an entry and the entry to the
The minimum difference of a character array is defined as the minimum value of the difference between an entry and the entry to the left. For example, the minimum difference of {'k', 'y', 't', 'a', 'n', 'p', 'r') is -24 because the difference between the 'a' and the 'y' to its left of 'a' is -24 and no other difference between an entry and another entry to its left is smaller. As another example, minimum difference of {"%', '$', '@', 'S', '(','-') is -28. (a) Write an efficient algorithm to find the minimum difference of a character array. Your method should take a character array as a parameter and return the minimum difference if it can be calculated. Note that array length should be greater than two. Throw appropriate exceptions when necessary. Make sure to give few test cases including the ones I provided. (20 points) (b) What is the running time of your algorithm? - You can include the answer to this question inside the javadoc comment of the method. (10 points)
Step by Step Solution
There are 3 Steps involved in it
public class MinimumDifference public static int findMinimumDifferencechar ... View full answer
Get step-by-step solutions from verified subject matter experts
