
算法与数据结构
文章平均质量分 73
qwyang
这个作者很懒,什么都没留下…
展开
-
堆排序算法实现 c语言
#include //小根堆得操作最重要在于heapAjust,即堆的调整,调整的时候是从上至下的调整,每次调整复杂度不超过树//的深度,即logN,由于建堆操作是从低(父节点n/2到1)向上全部调整一遍,所以建堆操作不超过nlogN的复杂度。//堆排序0位置是不使用原创 2011-10-12 11:33:41 · 1996 阅读 · 0 评论 -
kmp
#include #include using namespace std;int* next = NULL;void initNext(const char* substr){//得到next数组 int len = strlen(substr);原创 2011-10-11 14:45:30 · 311 阅读 · 0 评论 -
自己实现的malloc 和 free 函数
/*this file implement my own malloc() and free();the managed memory is a global char array called buf which is 1000 bytes big;HeadStru原创 2011-10-02 10:34:55 · 1652 阅读 · 3 评论 -
数据结构图:Floyd求最短路径算法
//Floyd最短路径算法思想:对每条链接尝试插入新节点后计算代价,然后和原代价进行比较,如果新代价较小,则更新代价矩阵//Floyd算法使用3层for循环,内2层循环用于更新花费矩阵和路径记录矩阵,外循环进行插入尝试找新的最短路径//两个辅助矩阵cost[ ][ ]和p原创 2011-10-12 17:07:58 · 1111 阅读 · 0 评论 -
c语言实例 文件拷贝copy命令实现
#include #include #include #include int main(int argc,char *argv[]) { FILE *to,*from; size_t size;原创 2011-10-02 13:13:59 · 1515 阅读 · 0 评论 -
二叉搜索树的实现 C++
#include using namespace std;typedef struct BSTNode{int data;struct BSTNode *lchild,*rchild;}BSTNode;class BSTree{//binary search tr原创 2011-10-04 15:49:46 · 366 阅读 · 0 评论 -
程序员必备flowchart练习一:getline()
作为flowchart练习根据流程图写代码:#include int getline(char *buf,int n){//return 0 means EOF//return & (Ctr+Z) by keyboard generates原创 2011-10-17 21:58:34 · 555 阅读 · 0 评论 -
银行模拟:队列的应用,软件方法应用
#include #include #include enum EventType{ENTER,LEAVE};struct Event{ EventType type; int startTime; int queNum;};class EventList{public: EventList(){ l原创 2011-11-16 11:07:54 · 383 阅读 · 0 评论 -
迷宫问题的实现
#include #define MAX 5int maze[MAX][MAX]={{0,0,1,0,0},{0,0,0,0,1},{0,0,0,1,1},{0,0,0,0,1},{0,0,1,0,0}};int inThePath[MAX][MAX];//to indicate wether (x,y) is in the current path, an o原创 2011-10-30 16:09:51 · 322 阅读 · 0 评论