416 views
1 votes
1 votes
Consider a procedure find ( ) which take array of n integers as input and produce pair of elements of array whose difference is not greater than the difference of any other pair of element of that array. Which of the following represent worst case time complexity of find ( ) procedure?
 

I am not getting what this question want to ask, Does it want pair with smallest difference.

Also do elements in pair need to be adjutant to each other?

It will really helpful if explained with small example

1 Answer

1 votes
1 votes
TIME COMPLEXITY IS O ( n log n) by sorting the elements in ascending order by merge sort and fiding out the pairwise differences with time complexity O (n).

hence the time complexity is O (n).

No related questions found