数据结构程序
BrianOne
learning something about AI
展开
-
数据结构与C++重温
文章目录1 配置VS环境1.1 高版本默认不能使用scanf函数1.2 输入齐全的头文件2 C++基本语法易忘点整理3 C++标准模板库STL3.1 vector向量:“边长数组”3.2 set集合:元素自动去重并按升序排列(头文件#include)3.3 string字符串1 配置VS环境1.1 高版本默认不能使用scanf函数配置:项目->属性->C/C+±>预处理器-...原创 2020-04-01 22:35:06 · 254 阅读 · 0 评论 -
数据结构-哈夫曼编码
#include<iostream>#include<algorithm>using namespace std;typedef int WeightType;typedef char ElementType;/*哈夫曼树的定义*/typedef struct HuffmanNode *PtrToHuffmanNode;struct Huffma...原创 2019-04-23 17:33:55 · 358 阅读 · 0 评论 -
数据结构-【2.2】堆栈的定义与操作-顺序表-C语言代码
typedef struct SNode *PtrToSNode;struct SNode { ElementType Data; PtrToSNode Next;};typedef PtrToSNode Stack; Stack CreateStack( ) { /* 构建一个堆栈的头结点,返回该结点指针 */ Stack S; S = (...原创 2019-04-22 07:20:24 · 181 阅读 · 0 评论 -
数据结构-【6.2】图的遍历-DFS与BFS-C语言代码
/* 邻接表存储的图 - DFS */ void Visit( Vertex V ){ printf("正在访问顶点%d\n", V);} /* Visited[]为全局变量,已经初始化为false */void DFS( LGraph Graph, Vertex V, void (*Visit)(Vertex) ){ /* 以V为出发点对邻接表存储的图Grap...原创 2019-04-23 08:33:07 · 702 阅读 · 0 评论 -
数据结构-【6.1】图的建立-邻接表-C语言代码
/* 图的邻接表表示法 */ #define MaxVertexNum 100 /* 最大顶点数设为100 */typedef int Vertex; /* 用顶点下标表示顶点,为整型 */typedef int WeightType; /* 边的权值设为整型 */typedef char DataType; /* 顶点存储的数据...原创 2019-04-22 07:22:15 · 645 阅读 · 0 评论 -
数据结构-【6.1】图的建立-邻接矩阵表示-C语言代码
/* 图的邻接矩阵表示法 */ #define MaxVertexNum 100 /* 最大顶点数设为100 */#define INFINITY 65535 /* ∞设为双字节无符号整数的最大值65535*/typedef int Vertex; /* 用顶点下标表示顶点,为整型 */typedef int WeightType; ...原创 2019-04-22 07:22:05 · 508 阅读 · 0 评论 -
数据结构-【5.3】集合的定义与并查操作-C语言表示
#define MAXN 1000 /* 集合最大元素个数 */typedef int ElementType; /* 默认元素可以用非负整数表示 */typedef int SetName; /* 默认用根结点的下标作为集合名称 */typedef ElementType SetType[MAXN];...原创 2019-04-22 07:22:25 · 1562 阅读 · 0 评论 -
数据结构-【5.1】堆的定义与操作-C语言代码
typedef struct HNode *Heap; /* 堆的类型定义 */struct HNode { ElementType *Data; /* 存储元素的数组 */ int Size; /* 堆中当前元素个数 */ int Capacity; /* 堆的最大容量 */};typedef Heap MaxHeap; /* 最...原创 2019-04-22 07:21:55 · 202 阅读 · 0 评论 -
数据结构-【4.2】平衡二叉树AVL旋转与插入-C语言代码
typedef struct AVLNode *Position;typedef Position AVLTree; /* AVL树类型 */struct AVLNode{ ElementType Data; /* 结点数据 */ AVLTree Left; /* 指向左子树 */ AVLTree Right; /* 指向右子树 */ in...原创 2019-04-22 07:21:42 · 202 阅读 · 0 评论 -
数据结构-【4.1】二叉搜索树插入与删除-C语言代码
BinTree Insert( BinTree BST, ElementType X ){ if( !BST ){ /* 若原树为空,生成并返回一个结点的二叉搜索树 */ BST = (BinTree)malloc(sizeof(struct TNode)); BST->Data = X; BST->Left = BST...原创 2019-04-22 07:21:31 · 196 阅读 · 0 评论 -
数据结构-【3】二叉树定义和四种遍历-C语言代码
typedef struct TNode *Position;typedef Position BinTree; /* 二叉树类型 */struct TNode{ /* 树结点定义 */ ElementType Data; /* 结点数据 */ BinTree Left; /* 指向左子树 */ BinTree Right; /* 指向右子树 */};...原创 2019-04-22 07:21:20 · 701 阅读 · 0 评论 -
数据结构-【2.3】队列的定义与操作-链式存储-C语言代码
typedef struct Node *PtrToNode;struct Node { /* 队列中的结点 */ ElementType Data; PtrToNode Next;};typedef PtrToNode Position; struct QNode { Position Front, Rear; /* 队列的头、尾指针 */ i...原创 2019-04-22 07:21:07 · 183 阅读 · 0 评论 -
数据结构-【2.3】队列的定义与操作-顺序存储-C语言代码
typedef int Position;struct QNode { ElementType *Data; /* 存储元素的数组 */ Position Front, Rear; /* 队列的头、尾指针 */ int MaxSize; /* 队列最大容量 */};typedef struct QNode *Queue; Qu...原创 2019-04-22 07:20:52 · 229 阅读 · 0 评论 -
数据结构-【2.2】堆栈的定义与操作-链式存储-C语言代码
typedef struct SNode *PtrToSNode;struct SNode { ElementType Data; PtrToSNode Next;};typedef PtrToSNode Stack; Stack CreateStack( ) { /* 构建一个堆栈的头结点,返回该结点指针 */ Stack S; S = (...原创 2019-04-22 07:20:40 · 132 阅读 · 0 评论 -
数据结构-【2.2】堆栈的定义与操作-顺序存储-C语言代码
typedef int Position;struct SNode { ElementType *Data; /* 存储元素的数组 */ Position Top; /* 栈顶指针 */ int MaxSize; /* 堆栈最大容量 */};typedef struct SNode *Stack; Stack CreateStack(...原创 2019-04-21 21:19:05 · 283 阅读 · 0 评论 -
数据结构-【2.1】线性表的定义与操作-链式表-C语言代码
typedef struct LNode *PtrToLNode;struct LNode { ElementType Data; PtrToLNode Next;};typedef PtrToLNode Position;typedef PtrToLNode List; /* 查找 */#define ERROR NULL Position Find( ...原创 2019-04-21 21:16:32 · 464 阅读 · 0 评论 -
数据结构-【2.1】线性表的定义与操作-顺序表-C语言代码
typedef int Position;typedef struct LNode *List;struct LNode { ElementType Data[MAXSIZE]; Position Last;}; /* 初始化 */List MakeEmpty(){ List L; L = (List)malloc(sizeof(struc...原创 2019-04-21 21:12:22 · 255 阅读 · 0 评论