retagged by
3,449 views
1 votes
1 votes
The minimum number of comparisons required to find the minimum and maximum of 60 numbers is..............
retagged by

1 Answer

Best answer
1 votes
1 votes
General formula is $\left \lceil 3\frac{n}{2} -2\right \rceil$

Here is how it works

Take 2 pointers smallest and largest

Compare 1&2 element of array assign least element to smaller and greater element to largest

 

So for n=60

Total compressions=1

Now take element 3&4 compare

Compare least element with smaller and greatest element with largest

Continue so on

Eg 5,3,1,2

5>3. 1st comparison

Smaller=3 larger=5

Now 1<2 2nd comparison next 3<1 3rd compressions & 5>2 4th comparison

So total comparison 4

When n is odd 1 St element is assigned as small as well as largest and remaining procedure is same

 

So for n=60 = 3*60/2-2= 88
selected by
Answer:

Related questions

2 votes
2 votes
2 answers
1
iarnav asked Mar 30, 2018
1,088 views
The minimum number of comparisons required to find the minimum and the maximum of 101 numbers is ________.When n is even then it's relatively easy, but how to deal with n...
2 votes
2 votes
1 answer
2
0 votes
0 votes
1 answer
4
Raghav Khajuria asked Oct 13, 2018
322 views
Minimum no of comparisons required to find the minimum and maximum of n distinct elements