## How many comparisons are needed to find the minimum element in a set? The maximum?

## Can we find the minimum and maximum with less than twice the cost?

## Yes:

- Walk through elements by pairs
- Compare each element in pair to the other
- Compare the largest to maximum, smallest to minimum

- Total cost: 3 comparisons per 2 elements = O(3n/2)

- Walk through elements by pairs

Previous slide | Next slide | Back to first slide | View graphic version |