phoenixwhiterose
New member
- Joined
- Sep 6, 2006
- Messages
- 9
Determine the least number of comparisons, or best case performance required to find the maxium of a sequence of n integers using algorithm 1.
Algorithm 1: procedure max(a1, a2, ...., an: integers)
max:=a1
for i:= 2 to n
if max < ai then max := ai
[max is the largest element]
I don't understand how to set up the comparisons, or come to the best case performance. Any help would be appreciatted, thank you.
Algorithm 1: procedure max(a1, a2, ...., an: integers)
max:=a1
for i:= 2 to n
if max < ai then max := ai
[max is the largest element]
I don't understand how to set up the comparisons, or come to the best case performance. Any help would be appreciatted, thank you.