edited by
386 views
1 votes
1 votes

edited by

1 Answer

Best answer
1 votes
1 votes

Sort the array.

Now do a pass through the array similar to the inner loop of selection sort as follows:

min = 0;
for(int i = 1; i< n-1; i++)
{
    if(diff(A[i], A[i+1]) < diff(A[min], A[min+1]) )
        min = i;
}

Finally A[min], A[min+1] give our required numbers.

selected by
Answer:

Related questions

0 votes
0 votes
2 answers
4
rahul sharma 5 asked Dec 8, 2017
1,006 views
Which of the following sorting techniques have best time complexity, if complexity is measured in terms of number of comparison? A Insertion sortB Selection sortC Merge s...