2012年11月3日

中序线索化二叉树

摘要: #include <stdio.h>#include <malloc.h>#define MaxSize 100typedef struct node { char data; int ltag,rtag;//增加的线索标记 struct node *lchild; struct node *rchild;} TBTNode;void CreateTBTNode(TBTNode * &b,char *str);//建立的二叉树void DispTBTNode(TBTNode *b);//输出二叉树TBTNode *CreaThread(TBTNode *b);/ 阅读全文

posted @ 2012-11-03 17:46 IThinktan 阅读(4923) 评论(1) 推荐(0) 编辑

无向图的深度优先生成树和广度优先生成树

摘要: #include <stdio.h>#include <malloc.h>#define MAXV 100//最大顶点个数int visited[MAXV];//全局数组typedef int InfoType;typedef struct { int edges[MAXV][MAXV];//邻接矩阵 int vexnum,arcnum; //顶点数,弧数} MGraph;//图的邻接矩阵类型typedef struct ANode { int adjvex; //该弧的终点位置 ... 阅读全文

posted @ 2012-11-03 16:50 IThinktan 阅读(13941) 评论(0) 推荐(0) 编辑

Prim算法求最小生成树

摘要: 数据结构书P189---图7.34#include <stdio.h>#define MAXV 100 //最大顶点个数#define INF 32767 //INF表示∞typedef struct { int edges[MAXV][MAXV];//邻接矩阵 int vexnum,arcnum; //顶点数,弧数} MGraph;//图的邻接矩阵类型void init(MGraph &g);//初始化邻接矩阵void DispMat(MGraph g);//输出邻接矩阵gvoid prim(MGraph g,int v);... 阅读全文

posted @ 2012-11-03 14:26 IThinktan 阅读(1561) 评论(1) 推荐(0) 编辑

哈夫曼编码_静态库

摘要: #include <stdio.h>#include <string.h>#define N 50 //叶子结点数#define M 2*N-1 //树中结点总数typedef struct//哈夫曼树的节点{ char data[5]; //结点存储的单词 int weight; //权重(该单词出现次数) int parent; //双亲结点 int lchild; //左孩子结点 int rchild; //右孩子结点} HTNode;typedef struct//哈... 阅读全文

posted @ 2012-11-03 12:21 IThinktan 阅读(1280) 评论(0) 推荐(0) 编辑

导航