Question: Given an unsorted array A = { ai } n i = 1 of size n , provide an algorithm that finds r = max

Given an unsorted array A ={ai}
n
i=1 of size n, provide an algorithm that finds
r = max |ai aj |
i,j<=n
using at most O(n) comparisons on the worst case input. Bonus: design an algorithm which uses at most 3
2
n comparisons on the worst case input. Prove that your
algorithm is correct.

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 Programming Questions!