The following algorithm finds the maximum and minimum element of an array (a[]).
void MaxMin (int a[], int n, int max, int min)
{
int maxm, minm;
maxm=minm=a[0];
for (int j=1 ; j<n; j++)
{
if(a[j]>maxm)
maxm = a[j];
if (a[j]<minm)
minm = a[j];
}
max = maxm; min=minm;
}
a)Find the worst and average cases in term of the basic operations (comparison of two elements).
b) Find the order and the worst and average cases.
The following algorithm finds the maximum and minimum element of an array (a[]). void MaxMin (int...