Java Quick Sort quickSort1(double array[], int low, int n)

Here you can find the source of quickSort1(double array[], int low, int n)

Description

Quicksort from RoseIndia.

License

Open Source License

Parameter

Parameter Description
array a parameter
low a parameter
n a parameter

Declaration

@Deprecated
public static void quickSort1(double array[], int low, int n) 

Method Source Code

//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);
    }
}

Related

  1. quicksort(String a[], int lo0, int hi0)
  2. quickSort(String a[], int lo0, int hi0)
  3. quickSort(String[] str, int low, int high)
  4. quickSort(String[] strings, int begin, int length)
  5. quickSort(T[] array, int[] index, int left, int right)
  6. quickSort1(int target[], int fromIndex, int length, int[] coSort)
  7. quickSort2(int target[], int fromIndex, int length, int[] coSort)
  8. quickSortInt(int[] data, int[] dataIdx, int len)
  9. quickSortMaxToMin(int a[], int lo0, int hi0)