Here you can find the source of quickSort1(double array[], int low, int n)
Parameter | Description |
---|---|
array | a parameter |
low | a parameter |
n | a parameter |
@Deprecated public static void quickSort1(double array[], int low, int n)
//package com.java2s; //License from project: Open Source License public class Main { /**// w w w . j av a2 s . co m * Quicksort from RoseIndia. Fails if two elements are equal. Don't use. * From <a href= * "http://www.roseindia.net/java/beginners/arrayexamples/QuickSort.shtml" * >http://www.roseindia.net/java/beginners/arrayexamples/QuickSort.shtml<a> * * @param array * @param low * @param n */ @Deprecated public static void quickSort1(double array[], int low, int n) { int lo = low; int hi = n; if (lo >= n) { return; } double mid = array[(lo + hi) / 2]; while (lo < hi) { while (lo < hi && array[lo] < mid) { lo++; } while (lo < hi && array[hi] > mid) { hi--; } if (lo < hi) { double T = array[lo]; array[lo] = array[hi]; array[hi] = T; } } if (hi < lo) { int T = hi; hi = lo; lo = T; } quickSort1(array, low, lo); quickSort1(array, lo == low ? lo + 1 : lo, n); } }