예제 #1
0
파일: hyb.c 프로젝트: KonstantinosKr/cvxlb
/* approximate median of a point set */
static BOX* median (BOX **Pb, BOX **Pe, int d, int h)
{
  if (h == 0) return *(Pb + rand () % (Pe-Pb));
  else return median_of_three (median (Pb, Pe, d, h-1),
                               median (Pb, Pe, d, h-1),
                               median (Pb, Pe, d, h-1), d);
}
예제 #2
0
void quicksort(T *arr, int left, int right)
{
    int pivot;

    if (left < right)
    {
        median_of_three(arr, left, right);
        // pivot = hoare_partition(arr, left, right); // about 10%~15% slower, why?
        pivot = partition(arr, left, right);
        quicksort(arr, left, pivot - 1);
        quicksort(arr, pivot + 1, right);
    }
}