Partition the array into two odd length groups with minimized absolute difference between their median | C # program to minimise the median between partition array ; Function to find minimise the median between partition array ; Sort the given array [ ] arr ; Return the difference of two middle element of the [ ] arr ; Driver Code ; Size of [ ] arr ; Function that returns the minimum the absolute difference between median of partition array
using System ; class GFG { static int minimiseMedian ( int [ ] arr , int n ) { Array . Sort ( arr ) ; return Math . Abs ( arr [ n / 2 ] - arr [ ( n / 2 ) - 1 ] ) ; } public static void Main ( String [ ] args ) { int [ ] arr = { 15 , 25 , 35 , 50 } ; int n = arr . Length ; Console . WriteLine ( minimiseMedian ( arr , n ) ) ; } }