
算法
错_对
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
插入排序
// quick qort and binary search.cpp: 主项目文件。 #include #include #include #define SIZE 100 #define SIZE_SEED 100 using namespace std; void insert_sort(int arr[], int size) { int temp; for ( int i = 1;原创 2012-07-11 02:19:39 · 532 阅读 · 0 评论 -
快速排序(变种)
#include #include #include using namespace std; void swap(int& small, int& big) { int temp = small; small = big; big = temp; } int partion(int arr[], int left, int right) { int i = left-1 , j =原创 2012-07-19 01:44:16 · 691 阅读 · 0 评论 -
快速排序 (解决小划分文件)
#include #include #define M 20 using namespace std; static int count_insert = 0; static int count_partion = 0; void swap(int& small, int& big) { int temp = small; small = big; big = temp; } /* |简述原创 2012-07-19 04:00:14 · 977 阅读 · 0 评论 -
快速排序(三路划分)解决大量重复元素
#include #include #include #define M 20 using namespace std; static int count_insert = 0; static int count_partion = 0; typedef struct index { int left; int right; }index; void swap(int& sm原创 2012-07-19 05:52:04 · 5466 阅读 · 1 评论 -
计数排序
#include using namespace std; /* | 参数说明:输入数组in[], 输出数组out[], 输入数组长度,输入数组中的最大值。 | |数组count[]为计数数组,记录输入数组in中重复出现的元素的个数 */ void count_sort(int in[], int out[], int size, int max_value) { int* count原创 2012-07-18 00:57:29 · 606 阅读 · 0 评论 -
冒泡排序
冒泡排序,顾名思义,把最轻的向上浮动。对应的把最小的数向上浮动, 对应到数列中就是:从后向前,当list[n] #include using namespace std; void swap(int& small, int& big) { int temp; temp = small; small = big; big = t原创 2012-07-13 04:39:30 · 478 阅读 · 0 评论 -
堆排序
#include #define LEFT(i) (i<<2) #define RIGHT(i) ((i<<2)+1) using namespace std; void swap(int& small, int& big) { int temp = small; small = big; big = temp; } /* |把父节点和两个儿子节点做比较,把最原创 2012-07-12 17:40:49 · 1161 阅读 · 0 评论 -
快速排序(优化版)
#include #include #include using namespace std; void swap(int& big, int& small) { int temp = big; big = small; small = temp; } int partition(int data[],int left,int right) { int base=data[right原创 2012-07-11 15:50:26 · 1052 阅读 · 0 评论 -
创建最大堆
首先来观察一颗最大堆二叉树 和一个普通序列的映射情况:在序列中从length(LIST)/2+1 -> length(LIST)的元素都对应于二叉树的叶子节点,同时也是一颗独立的树,且最大数就是自己本身。 #include #define LEFT(i) (i<<2) #define RIGHT(i) ((i<<2)+1) using namespace st原创 2012-07-12 16:56:41 · 5003 阅读 · 0 评论 -
快速排序(详解)
#include #include #include using namespace std; void swap(int &small, int& big) { int temp; temp = small; small = big; big = temp; } void qSort(int arr[], int left, int right ) { int i, j, base;原创 2012-07-11 03:53:23 · 639 阅读 · 0 评论 -
选择排序
// quick qort and binary search.cpp: 主项目文件。 #include #include #include #define SIZE 100 #define SIZE_SEED 100 using namespace std; /* 交换两个数*/ void swap_f (int& small, int& big) { int temp=small;原创 2012-07-11 01:53:46 · 526 阅读 · 0 评论 -
二元搜索
#include void ChoiceSort(int list[], int len); void Swap(int&, int&); int BinarySearch(int list[],int key, int len); int Comp(int, int); void main() { const int SIZE=15; int list[SIZE]={10,15,20,3原创 2012-07-11 04:50:55 · 813 阅读 · 0 评论 -
如何做一名工程师
说实话,你是一位优秀的工程师候选人吗?你怎么评价自己?你面试过多少家公司?你拿到offer的比率是多少?试一下用以下的公式来计算。 x = 获得现场面试的公司数量 y = 拿到的 offer 数量 value = 100 * log(x) * y / x 如果你的计算结果小于90,请仔细阅读这篇文章;如果大于120,那你并不需原创 2015-08-28 09:09:06 · 2485 阅读 · 0 评论