of Find Largest
Worst case occurs when the input sequence is in increasing order (so that the largest is last).
Best case occurs when A1 is the largest. Then
the number of steps is
The average case is
though we are very lucky that this can be argued fairly simply.
There is a problem with this example, in that step 2 should count as roughly n regular steps. But this does not matter when we get to
CS1104 Main Page
Last Updated 01/05/2000
© L.Heath, 2000