- 博客(4)
- 收藏
- 关注
原创 排序系列之四 计数排序
计数排序顾名思义 通过计算某数在数组中的位置来确定其次序,是一种非比较的排序方法,且用下面的算法是稳定的。------算法导论学习笔记void countSort(int a[],int b[],int k){//k is more bigger than any members in a; int c[k]; for(int i=0;i<k;i++){
2013-09-21 09:57:58
332
原创 排序系列之三快速排序(递归每次选择数组中末尾数为基准)
#include using namespace std;void swap(int &a,int &b) {int temp=a; a=b; b=temp;} int partition(int a[], int p,int r){ int x=a[r]; int i=p; for(int j=p;j<r;j++){ if(a[j]<=x){ swap(a[
2013-09-14 21:46:07
922
原创 排序系列之二堆排序的非递归算法
#include using namespace std;/* run this program using the console pauser or add your own getch, system("pause") or input loop */int parent(int i){//此处数组从1开始 a[0]设置为0; return i/2;}int lchild(i
2013-09-14 10:32:21
479
原创 排序系列之一冒泡排序
学习日记,记此博客记录void swap(int &a,int &b){//交换俩数a=a+b;b=a-b;a=a-b;}void bubble(int a[],int size){coutfor(int i=size-1;i>=0;i--){for(int j=i-1;j>=0;j--){if(a[i]swap(a[i],a[j]);}}}
2013-09-13 23:43:41
388
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人