Here you can find the source of median7(double[] v)
private static double median7(double[] v)
//package com.java2s; //License from project: Open Source License public class Main { private static double median7(double[] v) { sortInPlace(v, 0, 5);/*from www. ja v a 2 s .c o m*/ sortInPlace(v, 0, 3); sortInPlace(v, 1, 6); sortInPlace(v, 2, 4); sortInPlace(v, 0, 1); sortInPlace(v, 3, 5); sortInPlace(v, 2, 6); sortInPlace(v, 2, 3); sortInPlace(v, 3, 6); sortInPlace(v, 4, 5); sortInPlace(v, 1, 4); sortInPlace(v, 1, 3); sortInPlace(v, 3, 4); return v[3]; } private static int median7(int[] v) { sortInPlace(v, 0, 5); sortInPlace(v, 0, 3); sortInPlace(v, 1, 6); sortInPlace(v, 2, 4); sortInPlace(v, 0, 1); sortInPlace(v, 3, 5); sortInPlace(v, 2, 6); sortInPlace(v, 2, 3); sortInPlace(v, 3, 6); sortInPlace(v, 4, 5); sortInPlace(v, 1, 4); sortInPlace(v, 1, 3); sortInPlace(v, 3, 4); return v[3]; } private static void sortInPlace(final double[] v, final int i, final int j) { if (v[i] > v[j]) { final double tmp = v[i]; v[i] = v[j]; v[j] = tmp; } } private static void sortInPlace(final int[] v, final int i, final int j) { if (v[i] > v[j]) { final int tmp = v[i]; v[i] = v[j]; v[j] = tmp; } } }