Median and Order statistics chapter 9.
Problem 9.1-1
We will use tournament sort and keep track of the elements which has a match with smallest element, then find minimum within them will need n-1 comparisons and then in the tournament tree we have numbers to keep track with, comparing in them will need comparisons. So the total will be as asked comparisons .
Problem 9.1-2
As the hint suggests we will make two lists and . We pairwise compare the elements and store the greater ones in and smaller ones in . So we need comparisons. Now we will find maximum in set and minimum in set . that will take exactly comparisons. Now If n is odd and one element is left then we have to compare this element with new min and max element, so it will need again 2 for odd .
So if the number is even then we need n/2 + n/2 + n/2 – 2 comparisons or 3 n/2 – 2 on the other hand if it is odd we need which makes it comparisons . ( I am not still satisfied with this analysis.. It may contain a flaw )