Question: Question 5: Given an unsorted array, give an algorithm that finds the two (different) indices i and j so that |A[i] A[j]| is minimum. Example

Question 5: Given an unsorted array, give an algorithm that finds the two (different) indices i and j so that |A[i] A[j]| is minimum. Example A =< 3, 11, 6, 19, 15 >. In this case the best indices are i = 1 and j = 3. |A[1] A[3]| = 3 is the minimum possible.

Please answer with an explanation of the algorithm in words.

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!