you have 32 numbers. What is the least number of comparison needed to find the 2nd smallest out of them.
As per me it 61 comparsisons are required. Compare first two number in list. Assign largest and second largest to them based on comparison. Now compare rest 30 numbers with two of them and assign largest and second largest based on comparison. So for rest of 30 numbers we have to do 2 comparison for each number . this answer is 30*2 + 1 = 61. Can 61 be reduced?
I happen to remember this one from my algorithms class. Take your list of 32 numbers and try to find the smallest number. Compare the first and second numbers, the third and fourth, etc. until you reduce the list by half and repeat. It will take 31 comparisons to find the smallest number as each comparison eliminates one possibility.
Once this has been complete, make a list of the numbers the smallest number has been compared to. There should be 5. It will take 4 comparisons to find the smallest of these 5 numbers, for a total of 35 comparisons.