Question: Algorithm EvenAverage(AO..n-1]) //Input: array A of integers of size n> 10 //output: the average value of even integers total - 0; count 0; average 0;

Algorithm EvenAverage(AO..n-1]) //Input: array A of integers of size n> 10 //output: the average value of even integers total - 0; count 0; average 0; fori 0 to n-1 do if(A[i] mod 2 = 0) I/A[] is even {total -- total + A[i]: count - count + 1; } endfor if(count != 0 ) average- total/count; return average The first 10 elements of the array have 75% probability that an element is even, and the remaining elements of the array have 50% probability of being even. Find the total number of additions as a function of n in the average case. n5 Bn-4 n+4 On-5
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
