//QUICKSORT HELPER FUNCTIONS //Konstantin Voevodski //CS112A1 Spring 2008 void swapReferences(int[] a, int i1, int i2) //swaps a[i1] and a[i2] { int temp = a[i1]; a[i1] = a [i2]; a[i2]= temp; } int median3(int[] a, int left, int right) //sorts a[left], a[center], a[right] in place //swaps the median of the 3 (a[center], which is the pivot) with a[right-1] //returns the pivot { int center = (left + right) / 2; if(a[center] < a[left]) swapReferences(a,center,left); if(a[right] < a [center]) swapReferences(a,right,center); if(a[center] < a[left]) swapReferences(a,center,left); swapReferences(a,center,right-1); return a[right-1]; }