
数据结构
数据结构基础和一些算法题
小雄1994
https://github.com/happybear1234
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
树8 File Transfer (25分)
We have a network of computers and a list of bi-directional connections. Each of these connections allows a file transfer from one computer to another. Is it possible to send a file from any computer ...原创 2019-12-27 16:17:16 · 107 阅读 · 0 评论 -
05-树7 堆中的路径 (25分)
将一系列给定数字插入一个初始为空的小顶堆H[]。随后对任意给定的下标i,打印从H[i]到根结点的路径。输入格式:每组测试第1行包含2个正整数N和M(≤1000),分别是插入元素的个数、以及需要打印的路径条数。下一行给出区间[-10000, 10000]内的N个要被插入一个初始为空的小顶堆的整数。最后一行给出M个下标。输出格式:对输入中给出的每个下标i,在一行中输出从H[i]到根结点的路径上...原创 2019-12-26 17:31:26 · 188 阅读 · 0 评论 -
04-树7 二叉搜索树的操作集 (30分)
本题要求实现给定二叉搜索树的5种常用操作。函数接口定义:BinTree Insert( BinTree BST, ElementType X );BinTree Delete( BinTree BST, ElementType X );Position Find( BinTree BST, ElementType X );Position FindMin( BinTree BST );...原创 2019-12-25 16:49:22 · 144 阅读 · 0 评论 -
04-树6 Complete Binary Search Tree (30分)
A Binary Search Tree (BST) is recursively defined as a binary tree which has the following properties:The left subtree of a node contains only nodes with keys less than the node’s key.The right subt...原创 2019-12-25 11:29:50 · 95 阅读 · 0 评论 -
排序
//冒泡排序、插入排序、希尔排序、选择排序、堆排序、归并排序、快速排序#include <iostream>#include <queue>#define INF 1000000;//无穷大using namespace std;/*-----------------------------------------------冒泡排序--------------...原创 2019-12-17 17:23:55 · 102 阅读 · 0 评论 -
最小生成树:Prim算法和Kruskal算法
样例(无向图):1.Prim算法#include <iostream>#define MaxVertex 100#define INF 100000typedef int Vertex;typedef class MatrixGraph* MGraph;using namespace std;class MatrixGraph{public: void Bui...原创 2019-12-09 19:23:16 · 146 阅读 · 0 评论 -
有权图单源最短路径Dijkstra算法和多源最短路径Floyd算法
样例:1.Dijkstra算法#include <iostream>#include <stack>#define inf 1000000#define MaxVertex 100using namespace std;typedef int Vertex;typedef class MatrixGraph* MGraph;class MatrixGra...原创 2019-12-09 19:20:10 · 232 阅读 · 1 评论 -
邻接矩阵、邻接表(深度优先搜索、广度优先搜索)
1.邻接矩阵#include <iostream>#include <queue>#define MaxVertexNum 100using namespace std;typedef int WeightType;typedef int Datatype;typedef int Vertex;typedef struct GNode* ptrToGNode...原创 2019-12-03 19:54:46 · 558 阅读 · 0 评论 -
最大堆
#include <iostream>#define ERROR -1;using namespace std;typedef int Datatype;typedef struct HeapStruct* MaxHeap;struct HeapStruct{ Datatype *data;//存储堆元素的数组 int Size;//当前堆的容量 int Capac...原创 2019-12-03 18:46:17 · 126 阅读 · 0 评论 -
二叉搜索树和AVL
#include <iostream>using namespace std;typedef int Datatype;typedef struct TreeNode *BinTree;struct TreeNode{ Datatype data; BinTree Left; BinTree Right;};//创建BinTree CreateBinarySer...原创 2019-12-03 18:45:05 · 173 阅读 · 0 评论 -
二叉树遍历递归与非递归实现
递归实现:/*样例:3 4 6 0 0 7 8 0 0 0 0 前序:3 4 6 7 8 中序:6 4 8 7 3 后序:6 8 7 4 3*/#include <iostream>using namespace std;typedef class TreeNode BinTree;class TreeNode{public: TreeNode();...原创 2019-11-25 13:33:11 · 189 阅读 · 0 评论 -
循环队列的顺序存储和链式存储
顺序存储:#include <iostream>#define MAXSIZE 5//容量using namespace std;typedef int Datatype;typedef class Node Queue;class Node{public: Node(); ~Node() {}; void CreateQueue();//创建 int IsE...原创 2019-11-25 13:29:47 · 536 阅读 · 0 评论 -
栈的顺序存储和链式存储
顺序存储:#include <iostream>#define MAXSIZE 20//栈容量using namespace std;typedef int Datatype;typedef class Node Stack;class Node{public: Node(); ~Node() {}; void CreateStack();//创建 int I...原创 2019-11-25 13:25:53 · 172 阅读 · 0 评论 -
线性表顺序存储和链式存储
顺序存储:#include <iostream>#define MAXSIZE 20using namespace std;typedef int Datatype;typedef class ListNode List;class ListNode{public: ListNode() ; ~ListNode() {}; void CreateList();...原创 2019-11-18 14:26:58 · 148 阅读 · 0 评论