Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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)
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database Fundamentals Study Guide

Authors: Dr. Sergio Pisano

1st Edition

B09K1WW84J, 979-8985115307

Students also viewed these Databases questions