排序
Jason__Zhou
代码是朋友,可以真诚沟通,而且非常忠实。热爱你所写下的代码.
展开
-
快排 快速排序
快排 快速排序/* description: 快速排序参考<<编程珠玑>> author:Jason date:20160517 */ #include<stdio.h> #include<iostream> using namespace std;int show_data(int data[],int len) { cout<<"-----------------------"<<en原创 2016-05-17 12:38:45 · 726 阅读 · 0 评论 -
字符串的全排列 递归
/* description: 字符串的全排列来自<<编程之法>> author: JasonZhou date: 2016-03-11 */ #include <iostream> using namespace std;static int count=0; //递归方法 void CallAllPermutation(char* perm,int from,int to) {转载 2016-03-11 16:36:02 · 512 阅读 · 0 评论 -
bitmap排序
/* description: bitmap排序 https://github.com/julycoding/The-Art-Of-Programming-By-July/blob/master/ebook/zh/06.07.mdauthor: JasonZhou date: 2016-03-10 */ //定义每个Byte中有8个Bit位 #include<memory.h> #incl转载 2016-03-10 21:41:02 · 484 阅读 · 0 评论 -
桶排序 O(n) 线性时间
桶排序 (Bucket sort)或所谓的箱排序,是一个排序算法,工作的原理是将数组分到有限数量的桶子里。每个桶子再个别排序(有可能再使用别的排序算法或是以递归方式继续使用桶排序进行排序)。桶排序是鸽巢排序的一种归纳结果。当要被排序的数组内的数值是均匀分配的时候,桶排序使用线性时间(Θ(n))。但桶排序并不是 比较排序,他不受到 O(n log n) 下限的影响。假定:输入是由一个随机过程产生的[0转载 2015-07-19 21:01:18 · 567 阅读 · 0 评论 -
计数排序
/* 函数:计数排序 当k=O(n)时,排序时间是O(n) 核心思想 对于每一个元素,确定小于x的元素个数a. 利用这一个信息直接将该元素放到a+1位置上.需要都为正数. 时间:15.7.16 Jason Zhou 热爱你所写下的程序,他是你的伙伴,而不是工具. */ #include<iostream> using namespace std; int count_sort(int arr原创 2015-07-19 20:58:28 · 405 阅读 · 0 评论 -
计数排序
/* 函数:计数排序 当k=O(n)时,排序时间是O(n) 核心思想 对于每一个元素,确定小于x的元素个数a. 利用这一个信息直接将该元素放到a+1位置上. 需要都为正数. 时间:15.7.16 Jason Zhou 热爱你所写下的程序,他是你的伙伴,而不是工具. */ #include using namespace std; int count_sort(int arr[原创 2015-07-16 11:09:31 · 433 阅读 · 0 评论 -
快速排序 随机化版本
/* 函数:快速排序 a[p..q-1] 中的每一个元素小于a[q] a[q+1..r] 中的每个元素均大于a[q] 通过产生随机数的方法,保证等概率从候选项中选择主元. 时间:15.7.15 Jason Zhou 热爱你所写下的程序,他是你的伙伴,而不是工具. */ #include<iostream> #include<stdlib.h> #include <time.h> using na原创 2015-07-15 20:39:47 · 624 阅读 · 0 评论 -
冒泡排序
/* 函数:冒泡排序 从小到大排序 算法复杂度 n^2 时间:15.7.12 Jason Zhou 热爱你所写下的程序,他是你的伙伴,而不是工具. */#include <iostream> using namespace std;int bubble_Sort(int arr[],int len) { for (int i=0;i<len;i++) {原创 2015-07-12 14:52:17 · 410 阅读 · 0 评论 -
插入排序
/* 名称:插入排序 描述:将长度为length的数组,进行排序. flag=0 从小到大排序 flag=非0 从大到小排序 时间:15.7.11 Jason Zhou 热爱你所写下的程序,他是你的伙伴,而不是工具. */#include<iostream> using namespace std;int insertion_sort(int arr[],int length,int f原创 2015-07-11 17:14:56 · 478 阅读 · 0 评论
分享