Java Median median_of_3(int[] x, int x_ptr)

Here you can find the source of median_of_3(int[] x, int x_ptr)

Description

mediao_

License

Open Source License

Declaration

static int median_of_3(int[] x, int x_ptr) 

Method Source Code

//package com.java2s;

public class Main {
    static int median_of_3(int[] x, int x_ptr) {
        int t0, t1, t2;
        if (x[x_ptr] > x[x_ptr + 1]) {
            t0 = x[x_ptr + 1];/*from   ww w. j ava  2  s. c o  m*/
            t1 = x[x_ptr];
        } else {
            t0 = x[x_ptr];
            t1 = x[x_ptr + 1];
        }
        t2 = x[x_ptr + 2];
        if (t1 < t2) {
            return t1;
        } else if (t0 < t2) {
            return t2;
        } else {
            return t0;
        }
    }
}

Related

  1. median(long[] array)
  2. median(Number[] array)
  3. median(short[] arr)
  4. median3(double[] v)
  5. median7(double[] v)
  6. median_sorted(double[] sorted)
  7. medianAndSort(double[] a)
  8. medianElement(float[] array, int size)
  9. medianFilter(double[] array, int window)