- 浏览: 16046 次
最新评论
文章列表
交换排序--快速排序
- 博客分类:
- 算法
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[ ...
public void BubbleSort(T[] a)
{
T temp;
boolean flag;
for(int i=a.length-1;i>0;i--)
{
flag=true;
for(int j=0;j<i;j++)
{
if(a[j].compareTo(a[j+1])>0)
{
temp=a[j];
a[j]=a[j+1];
a[j+1]=temp;
flag=false;
}
}
if(flag)
...