Question: public static int minPosition ( double [ ] list ) The minPosition function returns the position ( index ) of the minimum value in an

public static int minPosition(double[] list)
The minPosition function returns the position (index) of the minimum value in an array of doubles. Note,
the first position in an array is 0 and the last is the array.length-1. You can assume the array is nonempty
and has no duplicates. Your solution must go through the array exactly once. Your solution must not call
any other functions. Here are some examples:
minPosition(new double[]{-7})==>0
minPosition(new double[]{1,-4,-7,7,8,11})==>2
minPosition(new double[]{-13,-4,-7,7,8,11)==>0
minPosition(new double[]{1,-4,-7,7,8,11,-9})==>6
public static int distanceBetweenMinAndMax(double[] list)
The distanceBetweenMinAndMax function returns difference between the minPosition and the
maxPosition in an array of doubles. The difference must be a positive number or 0. You can assume the
array is nonempty and has no duplicates. Your solution must go through the array exactly once. Your
solution must not call any other functions. Here are some examples:
distanceBetweenMinAndMax(new double[]{-7})==>0(-7 is both the min and max)
distanceBetweenMinAndMax(new double[]{1,-4,-7,7,8,11})==>3(-7,11)
distanceBetweenMinAndMax(new double[]{-13,-4,-7,7,8,11})==>5(-13,11)
distanceBetweenMinAndMax(new double[]{1,-4,-7,7,8,11,-9})==>1(-9,11)
 public static int minPosition(double[] list) The minPosition function returns the position

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!