Discrete math Describe using pseudocode an algorithm that ta

Discrete math

Describe (using pseudocode) an algorithm that takes a list of n integers (n GT 1) and finds the average of the largest and smallest integers in the list.

Solution

smallest = 0;

largest= 0;

for(int i=0;i<list.length;i++){

if(L(i) <smallest){

smallest=L(i)

}

else if(L(i)>largest){

largest = L(i);

}

return (largest+smallest)/2;

}

Discrete math Describe (using pseudocode) an algorithm that takes a list of n integers (n GT 1) and finds the average of the largest and smallest integers in th

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site