Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
public class MinimumDifference public static int findMinimumDifferencechar ...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