![](https://img-blog.csdnimg.cn/20201014180756925.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构和算法
linux_birds
这个作者很懒,什么都没留下…
展开
-
线索化二叉树的中序遍历
typedef enum PointerTag{Link,Thread};typedef struct BiThrNode{ TElemType data; struct BiThrNode *lchild,*rchild; PointerTag LTag, RTag;}BiThrNode, *BiThrTree;Status InOrderTraverse_原创 2009-01-21 14:18:00 · 362 阅读 · 0 评论 -
中序线索化二叉树的非递归版本
Status InOrderThreading(BiThrTree &Thrt,BiThrTree &T){ if (!Thrt=(BiThrTree)malloc(sizeof(BiThrNode))) { exit(overflow); } Thrt->LTag = Link; Thrt->RTag = Thread; Thrt->rchild = Thr原创 2009-01-22 09:45:00 · 409 阅读 · 0 评论 -
二叉树的非递归遍历
此三个算法可视为标准算法。1.先序遍历非递归算法#define maxsize 100typedef struct{ Bitree Elem[maxsize]; int top;}SqStack;void PreOrderUnrec(Bitree t){ SqStack s; StackInit(s); p=t;转载 2009-01-21 12:53:00 · 1014 阅读 · 2 评论 -
哈夫曼树从根到叶子的非递归遍历
//从根到叶遍历哈夫曼树 void HuffmanTreeRead(int n) { HC = (HuffmanCode)malloc((n + 1) * sizeof(char *)); m = n * 2 - 1; p = m; cdlen = 0; for ( i = 1; i <= m; ++i) { HT[i].weight = 0;原创 2009-01-23 10:39:00 · 821 阅读 · 0 评论 -
图的递归深度遍历
bool visited[MAX];Status(*VistiFunc)(int v);void DFSTraverse(Graph G, Status(*visited(int v)){ VisitFunc = Visit; for ( v = 0; v < G.vexnum; ++v) { visited[v] = false; } for ( v原创 2009-01-24 10:37:00 · 254 阅读 · 0 评论 -
哈夫曼树的构造和编码(叶子到跟)
//构造哈夫曼树并求哈夫曼编码void HuffmanCoding(HuffmanTree &HT,HuffmanCode &HC,int *w,int n){ //构造哈夫曼树 if ( n <= 1) { return; } m = 2 * n - 1; HT = (HuffmanTree)malloc((m+1)*sizeof(HTNode));原创 2009-01-23 09:19:00 · 365 阅读 · 0 评论 -
数据结构 严蔚敏版(快速排序小bug改正)
int Partition(SqList L, int low, int high) { L.r[0] = L.r[low]; pivotkey = L.r[low].key; while (low < high) { while (low原创 2009-02-11 10:11:00 · 1617 阅读 · 0 评论