SHARE
TWEET

Quick sort median pivot

a guest May 3rd, 2014 263 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.    function selectPivot(array $array)
  2.    {
  3.       $x      = $array[0];
  4.       $y      = $array[(int)(count($array)/2)];
  5.       $z      = $array[count($array)-1];
  6.       if($x>=$y)
  7.       {
  8.          if($y>=$z)
  9.             return $y;
  10.          return $x>=$z?$z:$x;
  11.       }
  12.       if($x>=$z)
  13.          return $x;
  14.       return $y>=$z?$z:$y;
  15.    }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top