Question: 3-3 write a function that given an array and its length, returns the weighted average of the array, defined as x . win where x

 3-3 write a function that given an array and its length,

3-3 write a function that given an array and its length, returns the weighted average of the array, defined as x . win where x represents all the distinct elements in the array, w, represents how many times the value of element x, appears in the array, and n is the size of the array. eg. if the array is (1,2,1,4.1,3 the weighted average is (1 . 3 / 6) + (21/6) + (1-3/6)+(41/6) + (1-3/6) + (31/6)-3.0. The function must return 0 if the size parameter, n, is less than 1. Signature: double welghtedaverage(int arrayll, int n)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!