交换排序--快速排序

private int partion(int[] a, int low ,int height)
	{
		int provkey=a[low];
		while(low<height)
		{
			while(low<height && provkey<=a[height])
				height--;
			a[low]=a[height];
			while(low<height && provkey>a[low])
				low++;
			a[height]=a[low];
		}
		a[low]=provkey;
		return low;
	}
public void sort1(int[] a, int low, int height)
	{
		int loc;
		if(low<height)
		{
			loc=partion(a,low,height);
			sort(a,low,loc);
			sort(a,loc+1,height);
		}
	}

数据结构排序总结,C++版,参看地址 http://www.cnblogs.com/mingcn/archive/2010/10/17/Sort.html#4

你可能感兴趣的:(快速排序)