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 even elements of an Array using Recursion
- C++ Program to print an Array 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
- Generating subarrays using recursion
- Product of 2 Numbers 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
- Maximize the size of array by deleting exactly k sub-arrays to make array prime
Improved By : jit_t