Question: In java, write an (n log n) recursive divide and conquer algorithm for the following problem: (comments in code for major steps) Given an array

In java, write an (n log n) recursive divide and conquer algorithm for the following problem: (comments in code for major steps)

Given an array that contains n values of doubles, find the two indexes with the biggest difference, where the larger number must be in an index later in the array than the smaller number.

For example:

Given n = 10, Array = [86.3, 29.38, 59.6091, 29.29, 36.5, 54.01, 22.21, 63.8, 15.75, 29.25]

Should return index 6 for the smaller value cell location, index 7 for the larger value cell location, and the difference of 41.59.

Given n = 5, Array = [23,3,9,16,2]

Should return index 1 for the smaller, index 3 for the larger and the difference of 13.

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!