算法导论
文章平均质量分 60
Dean_Winchester
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
【算法导论】C++参考源码之堆排序中的优先级队列
这篇例子中有几处BUG,无法插入新值,因为数组已经定义好了大小,解决方法:可以选择STL的容器来,也可以选择在已有的内存上使用动态分配。#include using namespace std;#define GET_ARRAY_LEN(array,len) {len = (sizeof(array) / sizeof(array[0]));}int length = 0;voi原创 2013-08-05 17:11:36 · 934 阅读 · 0 评论 -
【算法导论】C++源码之快速排序
以下内容包括:快速排序以及快速排序随机化版本#include using namespace std;int partition(int A[], int p, int r){ int x = A[r]; int i = p - 1; for (int j = p; j < r; ++j) { if (A[j] <= x) { ++i; swap(A[i]原创 2013-08-06 00:26:31 · 1017 阅读 · 0 评论 -
【算法导论】C++参考源码之线性时间排序
以下包含计数排序原创 2013-08-11 10:25:03 · 926 阅读 · 0 评论 -
【算法导论】C++参考源码之基础排序
开始阅读算法导论知识,数学部分的思路没有深究,只当是了解一些算法的原理以及思路,为的是熟悉算法以及在项目中能够应用到,没有打算对其进行学术研究,下面贴出对应我所写的C++源码,可以直接在VS2008编译器上运行。以下代码是是插入排序,合并排序(归并排序),冒泡排序,最大堆#include using namespace std;void insert_sort(int arry[原创 2013-08-04 20:26:23 · 912 阅读 · 0 评论 -
【算法导论】C++参考源码之队列、二叉树
简单的队列实现简单#include using namespace std;//-----------------------------------------------------------templatestruct Node{ Node(T d) : data(d), next(NULL) {} T data; Node* next;};//----------原创 2013-08-17 16:32:45 · 933 阅读 · 0 评论 -
【算法导论】C++参考源码之堆排序
以下包含了最大堆,建堆以及堆排序#include using namespace std;void max_heapify(int A[], int i, int size){ int largest; int l = 2 * (i + 1) - 1; int r = 2 * (i + 1); if (l A[i]) largest = l; else large原创 2013-08-05 00:32:03 · 1020 阅读 · 0 评论
分享