To find the mean of the elements of the array.
Mean = (Sum of elements of the Array) / (Total no of elements in Array)
Input : 1 2 3 4 5 Output : 3 Input : 1 2 3 Output : 2
To find the mean using recursion assume that the problem is already solved for N-1 ie you have to find for n
Sum of first N-1 elements = (Mean of N-1 elements)*(N-1) Mean of N elements = (Sum of first N-1 elements + N-th elements) / (N)
Note : Since array indexing starts from 0, we access N-th element using A[N-1].
This article is contributed by Prakhar Agrawal. If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to firstname.lastname@example.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please write comments if you find anything incorrect, or you want to share more information about the topic discussed above.
Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the DSA Self Paced Course at a student-friendly price and become industry ready.
- Find Harmonic mean using Arithmetic mean and Geometric mean
- Sum of elements in an array whose difference with the mean of another array is less than k
- Mean of array generated by products of all pairs of the given array
- Sum of array elements using recursion
- Program to check if an array is palindrome or not using Recursion
- Sum of array Elements without using loops and recursion
- Sum of even elements of an Array using Recursion
- C++ Program to print an Array using Recursion
- Mean of range in array
- Find mean of subarray means in a given array
- Find the missing integer in an array if mean is given
- Length of longest sub-array with maximum arithmetic mean.
- Removing a number from array without changing its arithmetic mean
- Count of elements that can be deleted without disturbing the mean of the initial array
- Program for Mean and median of an unsorted array
- Calculate Root Mean Kth power of all array elements
- Solving f(n)= (1) + (2*3) + (4*5*6) ... n using Recursion
- Sum of natural numbers using recursion
- Decimal to binary number using recursion
- Product of 2 Numbers using Recursion
Improved By : jit_t