
数据结构
DayThinking
这个作者很懒,什么都没留下…
展开
-
双链表的相关操作
// DoubleLinkTable.cpp : Defines the entry point for the console application.#include "stdafx.h"#include#includeusing namespace std;typedef struct node{ char data; struct node *next,*pre;}Lis原创 2012-05-09 09:45:14 · 2324 阅读 · 0 评论 -
数据结构与算法——排序算法篇
参考网站:http://www.cnblogs.com/morewindows/category/314533.html 什么情况下需要排序?其实很多的情况下,是否使用排序是一个重要的策略问题。很早以前人们使用排序,多数情况下是希望能够使用二分查找在logn的时间内取得想要的数据。乱序的情况下,只能使用顺序查找,需要n的时间才能够完成,平均情况下也是n/2,与logn差距太大。于是排序+二分查原创 2012-05-16 17:25:33 · 7814 阅读 · 3 评论 -
二叉树非递归遍历
1.先序遍历,先从递归说起void preOrder(TNode* root){ if (root != NULL) { Visit(root); preOrder(root->left); preOrder(root->right); }}递归算法非常的简单。先访问跟节点,然后访问左节点,再访问右节点。如果不用转载 2012-05-11 18:54:06 · 1038 阅读 · 0 评论 -
单链表的基本操作
// 单链表.cpp : 单链表的相关操作(两种方法的建立、两种方法的查询、求长、打印、插入、删除、逆序反转)。#include "stdafx.h"#includeusing namespace std;typedef struct node{ char data; struct node *next;}ListNode;typedef ListNode * LinkList;原创 2012-05-05 20:22:46 · 1104 阅读 · 0 评论 -
树的非递归遍历
在VS2011版本中调试通过。#include "stdafx.h"#include"Stack.h"//#include//标准库中定义的栈#includeusing namespace std;#define MAX_LEN 15void Create_tree(TreeNode **head, char *pData){ TreeNode *sop[MAX_LEN]原创 2012-05-17 10:08:51 · 877 阅读 · 0 评论 -
哈夫曼编码
//哈夫曼树构造原则: 权值小的在前,相等的单节点在前;#include "stdafx.h"#include #include #include typedef struct{ unsigned int weight; unsigned int parent,lchild,rchild;}HTNode,*HuffmanTree; typedef char **Huffm原创 2012-05-16 20:28:39 · 2834 阅读 · 0 评论 -
队列的基本操作
#include "stdafx.h"#includeusing namespace std;typedef struct node{ char data; struct node *link;//指向后缀结点的指针};typedef struct Queue{ node *first,*rear;//定义队列的头和尾指针};Queue * InsertQueue(Queu原创 2012-05-09 15:47:31 · 901 阅读 · 0 评论 -
栈的基本操作
#include "stdafx.h"#include#include#define OK 1#define TRUE 1#define ERROR 0#define FALSE 0#define overflow -2#define STACK_INTT_SIZE 100#define STACK_INIT_INCREMENT 20#define Status int#de原创 2012-05-11 09:13:12 · 10625 阅读 · 0 评论 -
数据结构及其应用
在程序的世界里,任何问题或技术的落脚点都是数据结构,所以在学习或研究这些问题或技术时,要注重理解底层或实现过程中所采用的数据结构。本系列会将常用的数据结构进行总结,首先看下树。一、树常用的树形数据结构有:搜索二叉树、平衡二叉树、红黑树、完全二叉树;1.搜索二叉树:父子节点满足大小关系,左子树都小于根节点,根节点都小于右子树,根据这一特性能快速进行查找;典型应用有:全球域名解析服务器的部署、...原创 2017-02-26 17:03:11 · 1710 阅读 · 0 评论