java实现快速排序

2014-11-24 09:44:17 · 作者: · 浏览: 0

java实现快速排序:

package study;
/**
 * 快速排序
 * @author WWX
 */
public class QuickSort {
	//获取中轴的位置
	private  int getMiddle(int [] list,int low,int high){
		int tmp=list[low];			//  的第一个作为中轴
		while(low=tmp){
				high--;
			}
			list[low]=list[high];   //比中轴小的纪录移到低端
			while(low0){
			_quickSort(a, 0, a.length-1);
		}
		return a;
	}
	
	//测试
	public static void main(String[] args) {
		 int[] list={34,3,53,2,23,7,14,10};  
		 QuickSort qs=new QuickSort();
		 list=qs.qucik(list);
		 for(int in:list){
			 System.out.println(in);
		 }
	}
}

输出结果:

2
3
7
10
14
23
34
53