bubble sort
来源:互联网 发布:mac无法添加qq邮箱 编辑:程序博客网 时间:2024/04/30 00:06
#include<stdio.h>#define N 10int source[N] = {1,5,3,2,7,9,4,10,6,8};int main(){int j;for(j=1;j < N;j++){ int i = j - 1; int key = source[j]; while(i >= 0 && source[i] > key) {source[i+1] = source[i];i = i - 1; } source[i+1] = key;}for(j = 0; j < N;j++) printf("%d ",source[j]);printf("\n");return 0;}
bubble sort 源码
与插入排序相似,最坏情况下,时间复杂度为 O(n^2)
最好去况下的时间复杂度为 O(n)
其平均的时间复杂度为 O(n^2)
但其无须额外的空间进行辅助排序 故空间复杂度为 O(1)
- Bubble sort
- Bubble Sort
- bubble sort
- Bubble Sort
- Bubble Sort
- bubble sort
- Bubble Sort
- Bubble Sort
- Bubble Sort
- Bubble Sort
- Bubble Sort
- Bubble Sort
- Bubble Sort
- Bubble sort
- Bubble Sort
- Bubble Sort
- Bubble Sort
- Bubble Sort
- 八皇后与汉诺塔问题
- WITH(NOLOCK)
- CAS-Client客户端研究(一)-AuthenticationFilter
- 金山卫士界面源码解读及界面库分离(2)
- QEMU, a Fast and Portable Dynamic Translator
- bubble sort
- symbian 错误 This project does not support program "BUILD_HELP" for platform "WINSCW"
- C文件操作函数
- 几种开放源码的TCP/IP协议栈比较
- 金山卫士界面源码解读及界面库分离(3)
- A very simple CTransInPlaceFilter example
- warning: dereferencing type-punned pointer will break strict-aliasing rules(转)
- GNU GLOBAL (gtags) 的常规使用
- 金山卫士界面源码解读及界面库分离(4)