Java examples for Data Structure:Sort
quick sort int array
//package com.java2s; public class Main { public static void quicksort(int[] bb, int low, int high) { int w = 0; if (low < high) { w = split(bb, low, high, w); quicksort(bb, low, w - 1);//w ww . j av a 2 s . c om quicksort(bb, w + 1, high); } } public static int split(int[] bb, int low, int high, int w) { int i = low; int x = bb[low]; for (int j = low + 1; j <= high; j++) { if (bb[j] <= x) { i = i + 1; if (i != j) { int temp = bb[i]; bb[i] = bb[j]; bb[j] = temp; } } } int temp = bb[low]; bb[low] = bb[i]; bb[i] = temp; w = i; return w; } }