Question: Consider the problem of computing the mean m and the variance v of n numbers stored in array A = (a1, a2 an). Here are
Consider the problem of computing the mean m and the variance v of n numbers stored in array A = (a1, a2 an). Here are the expressions to compute m and v m = [sum (ai for i = 1, 2 n)] / n v = [sum (ai2 for i = 1, 2 n) nm2] / (n-1)
a. Write a pseudo code to compute both m and v which takes the array A as input. The code has to be in one loop.
b. What are the loop invariants?
c. What is the asymptotic running time of your answer of part a. (25 points)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
