几种排序算法小结

阅读更多
//冒泡排序
public class BubbleSort {
	void bubbleSort(int []mp){
		for (int i = 0; i < mp.length; i++) {
			for (int j = 0; j mp[j+1]){
					int temp=mp[j];
					mp[j]=mp[j+1];
					mp[j+1]=temp;
				}
				
			}
			
		}
	}

}


//插入排序
//思想:后面一个跟前面所有的进行排序
public class InsertSort {
	void insertSort(int []cr){
		for(int i=0;ixz[j]){
					 temp=xz[j];
					 k=j;
				}
			}
			xz[k]=xz[i];
		   	xz[i]=temp;
		   	
		}
	
	}

}


//快速排序
public class QuickSort {
	void quickSort(int qs[]){
		int len=qs.length;
		
		quickSort2(qs, 0,len-1);
	}
	void quickSort2(int qs[],int left,int right){
		int pos;
		if(left=qs[left])&&(left 
 
  • 几种排序算法小结_第1张图片
  • 大小: 101.2 KB
  • 查看图片附件

你可能感兴趣的:(几种排序算法小结)