Professional Documents
Culture Documents
Statistics
Straight MaxMin(a,n,max,min)
{ max:=min:=a[1];
for(i:=2 to n do
{
if(a[i]>max) then max:=a[i];
if (a[i]<min) then min:=a[i];
}
}
University Institute of Engineering (UIE)
[2] [3]
[4]
22
13 -5
-8
[5]
15
[6]
60
[7]
17
[8]
[9]
31
47
Example
9
1,9,60,-8
6,9,60,17
1,5,22,-8
4
3
1,3,22,-5
4,5,15,-8
6
6,7,60,17
1,2,22,13
3,3,-5,-5
7
8,9,47,31
References
Fundamental of Computer Algorithms ,2nd
Edition,Sartaj Sahni, Ellis Horowitz, Sanguthevar
Rajasekaran, Chapter No.3 page no.153-158.