最全的排序算法及其优化
文章平均质量分 71
排序是计算机内经常进行的一种操作,其目的是将一组“无序”的记录序列调整为“有序”的记录序列。我的专栏里有冒泡排序及其优化,选择排序及其优化,堆排序,希尔排序,和快速排序及其优化,各种算法程序帮助你理解和领悟排序的思想,有助于排解同学们在排序里面的疑惑。
poison_biti
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
排序(全)
非比较排序:计数排序,基数排序直接插入排序“test.cpp”#includeusing namespace std;#includevoid InsertSort(int* arr,size_t size){ assert(arr); for(int i = 0;i < size-1;i++) { int j = i; int tmp = arr原创 2016-11-27 22:29:02 · 493 阅读 · 0 评论 -
堆应用——堆排序
"test.cpp"#includeusing namespace std;#includevoid AdjustDown(int* arr,size_t size,size_t root){ size_t parent = root; size_t child = 2*parent+1; while(child < size) { if(child+1 arr[ch原创 2016-10-12 23:50:24 · 733 阅读 · 0 评论 -
排序----冒泡排序的优化_选择排序_插入排序
"test.c"#define _CRT_SECURE_NO_WARNINGS 1#include "Sort.h"int main(){ int arr[] = {6,3,8,1,4,9,5,0,2,7}; int size = sizeof(arr)/sizeof(arr[0]); BubbingSort(arr,size); //SelectSort(ar原创 2016-06-01 21:39:18 · 807 阅读 · 0 评论 -
排序(2)——插入/希尔/选择/快速排序及优化
"Sort.h"#pragma once#include using namespace std;#include #include void InsertSort(int* arr,size_t size)//直接插入排序{ assert(arr); for (int i = 1;i < size;i++) { int j = i-1; i原创 2016-06-16 16:26:11 · 457 阅读 · 0 评论 -
排序(1)——冒泡排序及其优化
“test.cpp”#define _CRT_SECURE_NO_WARNINGS 1#includeusing namespace std;//优化趟数里的次数void BubbleSort_OP2(int* arr ,size_t size){ int n = 0; int m = size-1; bool flag = true; for(int i = 0;i <原创 2016-09-09 14:15:46 · 389 阅读 · 0 评论 -
排序(2)——选择排序及其优化
“test.cpp”#define _CRT_SECURE_NO_WARNINGS 1#includeusing namespace std;#includevoid SelectSort_OP(int* arr,size_t size){ assert(arr); int min = 0; int max = 0; for(int i = 0;i < size;i++)原创 2016-09-09 20:07:29 · 369 阅读 · 0 评论 -
排序(3)——插入排序
“test.cpp”#define _CRT_SECURE_NO_WARNINGS 1#includeusing namespace std;#includevoid InsertSort(int* arr,size_t size){ assert(arr); int i = 1; while(i < size) { int j = 0; int tmp = ar原创 2016-09-09 22:12:54 · 268 阅读 · 0 评论 -
排序(4)——希尔排序
“test.cpp”#define _CRT_SECURE_NO_WARNINGS 1#includeusing namespace std;#includevoid ShellSort(int* arr,size_t size){ assert(arr); int tmp = 0,i = 0,j = 0,count = size; do { count = coun原创 2016-09-09 22:14:17 · 310 阅读 · 0 评论 -
排序(5)——堆排序
“test.cpp”#define _CRT_SECURE_NO_WARNINGS 1#includeusing namespace std;#includevoid HeapAdjust(int* arr,int parent,size_t size){ assert(arr); int child = 2*parent+1; while(child && child <原创 2016-09-10 13:44:10 · 335 阅读 · 0 评论 -
排序(6)——快速排序及其优化
“test.cpp”#includeusing namespace std;int MidNode(int* arr,int left,int right){ int tmp = arr[left]; while(left < right) { while(left = tmp) { right--; } swap(arr[left],arr[right]原创 2016-09-13 18:48:28 · 369 阅读 · 0 评论
分享