![](https://img-blog.csdnimg.cn/20201014180756724.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构和算法
文章平均质量分 67
浪里寻星
这个作者很懒,什么都没留下…
展开
-
二叉搜索树非递归后序遍历的尝试
//非递归后序遍历void Porder2(BTNode * root) { BTNode **s; BTNode *sr;//右子树结点访问标记 BTNode *p; int top = -1; int tag = 0; s = (BTNode **)malloc(100 * sizeof(BTNode *)); p = root; do{ while(p && !原创 2014-10-29 01:04:03 · 358 阅读 · 0 评论 -
冒泡升序排序的数组实现和链表实现
void ArrayBubbleSort (int a[],int n){ int i,j,t,tag = 1; for(i = 1;i < n && tag;i++){ tag = 0; for(j = n-1;j >= i;j--) if(a[j-1] > a[j]){ t = a[j-1]; a[j-1] = a[j]; a[j] = t;原创 2014-11-01 01:51:34 · 408 阅读 · 0 评论 -
散列查找:C语言线性探查与拉链存储的实现
//散列查找:C语言线性探查与拉链存储的实现 #include #include #define LineSize 13typedef struct node{ int data; struct node *next;}ElemSN;//线性探查法存储 int * LinearProbing(int d[],int n){ int * const Plp = (int *原创 2014-11-03 02:24:37 · 688 阅读 · 0 评论 -
装箱问题的简单实现
//装箱问题的简单实现#include #include #include using namespace std;typedef struct{ int gno; int gv;}Goods;class GNode{ private: int gno; GNode * link = NULL; public: GNode(int gno){ this->原创 2014-11-24 02:09:34 · 644 阅读 · 0 评论 -
N皇后问题的简单实现
//N皇后问题的简单实现#include#include#includevoid PrintTheSulotion(int *Queen,int n){ for(int i=1;i<=n;i++){ for(int j=1;j<=n;j++){ if(j-Queen[i]) printf("O "); else printf("X "); } p原创 2014-11-29 00:12:36 · 281 阅读 · 0 评论 -
特殊情况下的排序算法(一)
有1,2,…,n的无序数组,求排序算法,并且要求时间复杂度为O(n),空间复杂度O(1),使用交换,而且一次只能交换两个数。#include int main() { int a[] = {10, 6, 9, 5, 2, 8, 4, 7, 1, 3}; int i, tmp; int len = sizeof(a) / sizeof(a[0]); for(i原创 2014-12-05 23:11:13 · 383 阅读 · 0 评论 -
哈夫曼树-贪心算法的应用实例
/**哈夫曼编码-链式结构* *功能实现: * 源文件字符权值确认操作 * 哈夫曼树的建立操作 * 字符字典的建立操作 * 源文件转码操作操作 * 二进制文件译码操作* 文件输出操作* 内存清理操作 */#include #include #define _HFMAlgorithm_#define codesize 30//哈夫曼树结点定义 typedef s原创 2014-12-07 23:11:35 · 3837 阅读 · 0 评论 -
树变成二叉树
/*问题描述:将树变成二叉树引例:《数据结构(C语言版)》清华大学出版社P135下图input.data 数据如下:10RARBRCRDAEAFCGFHFKF */#include #include #include #define MAX_TREE_SIZE 20typedef char TElemType; typedef原创 2014-12-13 17:03:19 · 573 阅读 · 0 评论