
个人练习--算法&数据结构 in C
文章平均质量分 70
超级土豆
码工
展开
-
C链表实现(单向,双向)
一、单向链表 #include <stdio.h> #include <stdlib.h> #define FALSE 0 #define TRUE 1 //#include "link.h" typedef struct NODE { struct NODE *link; int value; }No...2009-12-10 17:24:35 · 110 阅读 · 0 评论 -
B树实现
/*====================*\ | BTree.h | \*====================*/ #ifndef _BTREE_H_ #define _BTREE_H_ #define NUM 3 #define KeyType int #define Status int typedef struct BTNode { ...原创 2010-06-22 14:13:49 · 126 阅读 · 0 评论 -
AVL树实现
avl树是其每个节点的左子树和右子树的高度最多差1的二叉查找树。当在一棵avl树中插入节点的时候,很可能把avl树的平衡给破坏掉,在不平衡的情况下,可以通过对树做单次旋转或者复杂些的双旋转来处理。具体的旋转方法Google去 O(∩_∩)O,这里就不做详细介绍啦。下面仅给已实现的avl树的代码。 /*====================*\ | AvlTree.h | ...原创 2010-06-17 17:08:46 · 159 阅读 · 0 评论 -
查找树ADT-二叉查找树
/////////////////////////////// tree.h ///////////////////////////////// #ifndef _TREE_H_ #define _TREE_H_ #define ElementType int struct TreeNode; typedef struct TreeNode * Position; typedef...原创 2010-06-13 09:59:30 · 107 阅读 · 0 评论 -
生成表达式树
栈及中缀表达式转后缀表达式的实现看之前的日志 //>>>>>>mocro.h #ifndef _MACRO_H_ #define _MACRO_H_ #define EmptyTOS (-1) #define MinStackSize (5) #define ElementType int #endif //>&...原创 2010-06-12 14:06:59 · 198 阅读 · 0 评论 -
中缀表达式转后缀表达式的栈实现
/* Name:infixSuffixConv.c Copyright: personal Author: hojor Date: 10-06-10 21:24 Description: infix convert to suffix */ #include<stdio.h> #include<stdlib.h> #define ...原创 2010-06-10 21:08:03 · 115 阅读 · 0 评论 -
栈(stack)
/* Name: stack.c Copyright: personal Author: hojor Date: 07-06-10 10:22 Description: stack */ #include <stdio.h> #include <stdlib.h> #include "stack.h" #define Em...原创 2010-06-08 13:49:04 · 103 阅读 · 0 评论 -
最长公共子序列
用动态规划实现的最长公共子序列 #include<stdio.h> #include<stdlib.h> /*==============*\ |最长公共子序列 \*==============*/ /*!<打印最长公共子序列*/ void printLCS(char ** a,int m,int n,const char *s1, ...原创 2010-06-04 17:10:53 · 153 阅读 · 0 评论 -
基数排序
/*********************\ * 基数排序(桶排序)* \*********************/ #include<stdio.h> #include<stdlib.h> #include<string.h> #include<math.h> //struct of node typedef struc...原创 2010-06-04 10:35:51 · 95 阅读 · 0 评论 -
螺旋矩阵算法
自己写的一个螺旋矩阵的算法,感觉好笨,呵呵,还没想出好办法来,感觉肯定有个很简洁的算法来实现。 #include<stdio.h> #include<stdlib.h> void SpiralMatrix(int start,int n) { int sm[n][n],i,j; i=j=0; memset(sm,0...原创 2010-06-02 16:24:44 · 184 阅读 · 0 评论 -
最大子序列和问题的联机算法
#include<stdio.h> #include<stdlib.h> /*!\func int MaxSubsequenceSum(const int a[],int n) *\bref the problem about the max sum of subsequence *\para[in] a[] : th...原创 2010-06-02 00:22:04 · 194 阅读 · 0 评论 -
二叉堆(优先对列)
/*===========*\ | binheap.h | \*===========*/ #ifndef _BINHEAP_H_ #define _BINHEAP_H_ #define ElementType int #define MinPQSize 2 #define MinData -10000 typedef struct HeapStruct { i...原创 2010-06-25 13:02:27 · 115 阅读 · 0 评论