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 email@example.com. 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.
- Sum of array elements using recursion
- Sum of array Elements without using loops and recursion
- Program to check if an array is palindrome or not using Recursion
- Solving f(n)= (1) + (2*3) + (4*5*6) ... n using Recursion
- Product of 2 Numbers using Recursion
- Generating subarrays using recursion
- Sum of natural numbers using recursion
- Decimal to binary number using recursion
- Programs for printing pyramid patterns using recursion
- Find original array from encrypted array (An array of sums of other elements)
- Find an element in array such that sum of left array is equal to sum of right array
- Minimum cost to reach end of array array when a maximum jump of K index is allowed
- Find minimum value to assign all array elements so that array product becomes greater
- Print modified array after multiple array range increment operations
- Generate original array from an array that store the counts of greater elements on right
Improved By : jit_t