编辑代码

#include <stdio.h>
int BubbleSort(int a, int length){
    int i, j, temp;
    for(i = 0;i < n - 1; i++){
        for(j = 0;j < n - 1 - i;j++){
            if(a[j] > a[j + 1]){
                temp = a[j];
                a[j] = a[j + 1];
                a[j + 1] = temp;
            }
        }
    }
}
int QuickSort(int a, int length){
    int key;
}
int BucketSort(){
    int key;
}
int counting_sort(int arr,int maxValue){
    int bucketLen, bucket, sortedIndex, i, j;
    bucketLen = maxValue + 1;
    bucket = [0] * bucketLen
    sortedIndex = 0
    arrLen = sizeof(arr)
    for (i=0;i<arrLen;i++){
    if (bucket[arr[i]]){
        continue;
    }
    bucket[arr[i]] = 0
    bucket[arr[i]] ++
    for (j=0;j<bucketLen;j++){
    while (bucket[j] > 0){
    arr[sortedIndex] = j
    sortedIndex++
    bucket[j]--
    }
}
    return arr
    }
}
int main () {
      return 0;
}  
/* 快速排序是一种二叉树结构的交换排序方法,
其基本思想为:任取待排序元素序列中的某元素作为基准值 ,
按照该排序码将待排序集合分割成两子序列 ,
左子序列中所有元素均小于基准值,右子序列中所有元素均大于基准值,
然后最左右子序列重复该过程,直到所有元素都排列在相应位置上为止。
这一过程相当于二叉树的前序遍历,先让基准值排列在相应位置,
然后分割子序列,每次分割左右子序列都排好一个基准值,然后再分割左右子序列,
直到序列中只有一个元素时即为最小子问题,
当每一个根都排在了相应位置,那么序列就变得有序了,
所以很容易就想到了用递归来实现快速排序这一算法。*/