a) Write an algorithm that finds both the smallest and largest numbers in a list of n numbers
and calculate its complexity T(n).
b) Write an algorithm that finds both the smallest and largest numbers in a list of n numbers
and with complexity T(n) is at most about (1.5)n comparisons.
I think this will work. Let's change it up a bit. Say I put some numbers in a paper bag, gave you the paper bag and said take the numbers and tell me what the biggest and smallest number in the bag was. One way you could do it is to sort the numbers (however you wanted to do that) and report the extremes. But can you think of another way you could determine the largest and smallest without sorting the numbers first? If so, try adapting that approach to your problem.
No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.