int secondmax (int a[], int n)
{
int i, max, second;
for (i=0; i if (i==0 a[i]>max) second= max, max= a[i]; else if (i==1 a[i]>second) second= a[1]; } return second; } int middle (int a[3]) { return secondmax (a, 3); }
Sort the list using Quicksort & pick the middle item
Algorithm for average of 3 numbers:
[object Object]
1. Design an algorithm to compute sum of the squares of n numbers?
what is algorithm and its use there and analyze an algorithm
It is an algorithm used by another algorithm as part of the second algorithm's operation.As an example, an algorithm for finding the median value in a list of numbers might include sorting the numbers as a sub-algorithm: There are plenty of algorithms for sorting, and the specifics of the sorting does not matter to the "median value" algorithm, only that the numbers are sorted when the sub-algorithm is done.For what an algorithm is, see related link.
write an algorithm to compute the weekly average rainfall given the daily rainfall for four weeks
All algorithms have a best, worst and average case. Algorithms that always perform in constant time have a best, worst and average of O(1).
By dividing
Describe an algorithm for dividing rational numbers.
You can use Euclid's algorithm to calculate the gcf of two of the numbers - then use Euclid's algorithm again with the result and the third number.Or you can factor all the numbers into prime factors, and check which prime factors occur in all three numbers.
To calculate the average of two numbers, add them together, and divide the result by 2. (For the average of three numbers, you add up the three numbers, and divide by three, etc.) The average is (5000 + 7000)/2 = 6000
125, 126 and 127.
3, 5, and 7 are three prime numbers whose average is 5.
Yes. For example, the average of 5, 7, and 9 is 7.
The average of the numbers 51, 52, and 56 is 53. To get the average you would add all three numbers and then divide by three.
1. Design an algorithm to compute sum of the squares of n numbers?
12
The algorithm is A/B * C/D = AB/CD.
3, 5, and 7 are three prime numbers whose average is 5.