
数据结构
luer9
假如我年少有为。
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
PAT 1099 Build A Binary Search Tree (30分)
1099Build A 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 subtree of a node c..原创 2020-09-21 16:01:09 · 156 阅读 · 0 评论 -
PAT 1123 Is It a Complete AVL Tree (30分)(完全二叉平衡树)
1123Is It a Complete AVL Tree(30分) An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is done to restore t..原创 2020-09-20 21:41:31 · 160 阅读 · 0 评论 -
PAT 1127 ZigZagging on a Tree (30分)
1127ZigZagging on a Tree(30分) Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inorder traversal sequences. And it is a simple standard routine to print th..原创 2020-09-20 20:42:31 · 127 阅读 · 0 评论 -
PAT 1135 Is It A Red-Black Tree (30分) (红黑树)
1135Is It A Red-Black Tree(30分) There is a kind of balanced binary search tree namedred-black treein the data structure. It has the following 5 properties: (1) Every node is either red or black. (2) The root is black. (3) Every leaf (NULL) is black...原创 2020-09-20 17:36:12 · 146 阅读 · 0 评论 -
PAT 1151 LCA in a Binary Tree (建树+lca)
1151LCA in a Binary Tree(30分) The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that has both U and V as descendants. Given any two nodes in a binary tree, you are supposed to find their LCA. Input Specification: Eac..原创 2020-09-20 16:04:20 · 174 阅读 · 0 评论 -
PAT 1119 Pre- and Post-order Traversals (30分)
1119Pre- and Post-order Traversals(30分) Suppose that all the keys in a binary tree are distinct positive integers. A unique binary tree can be determined by a given pair of postorder and inorder traversal sequences, or preorder and inorder traversal seq..原创 2020-07-23 17:23:42 · 176 阅读 · 0 评论 -
PAT 1066 Root of AVL Tree (25分) (AVL模板)
1066Root of AVL Tree(25分) An AVL tree is a self-balancing binary search tree. In an AVL tree, the heights of the two child subtrees of any node differ by at most one; if at any time they differ by more than one, rebalancing is done to restore this prope..原创 2020-07-09 16:14:43 · 173 阅读 · 0 评论 -
PAT 1086 Tree Traversals Again(中,前,后)
1086Tree Traversals Again(25分) An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the keys numbered f...原创 2020-04-22 21:37:20 · 166 阅读 · 1 评论 -
PAT 1130 Infix Expression
1130Infix Expression(25分) Given a syntax tree (binary), you are supposed to output the corresponding infix expression, with parentheses reflecting the precedences of the operators. Input Specifica...原创 2020-03-28 14:24:08 · 182 阅读 · 0 评论 -
堆排序
构造大顶堆进行排序。 转载blog #include <bits/stdc++.h> void Swap(int *heap, int len); /* 交换根节点和数组末尾元素的值 */ void BuildMaxHeap(int *heap, int len);/* 构建大顶堆 */ int main() { int a[6] = {7, 3, 8,...转载 2019-08-20 09:10:02 · 128 阅读 · 0 评论 -
POJ 3264 Balanced Lineup (RMQ)
POJ3264 题意是:求区间最大值和最小值的差 RMQ(Range Minimum/Maximum Query),即区间最值查询,这是一种在线算法,所谓在线算法,是指用户每次输入一个查询,便马上处理一个查询。RMQ算法一般用较长时间做预处理,时间复杂度为O(nlogn),然后可以在O(1)的时间内处理每次查询。 RMQ详解 RMQ模板: #include <iostream&g...原创 2019-08-07 17:12:23 · 145 阅读 · 0 评论 -
数据结构_栈
点击一下吧hh 栈是特殊的线性表,特点:先进后出~~ 直接用STL很方便的,不过还是从底层重新学一遍吧。 如果你是为了找代码,应付老师的作业,建议右上角关掉窗口。 关于栈的一些操作 栈的顺序存储结构 #include <iostream> #include <cstring> #include <string> #include <cmath...原创 2018-10-12 20:21:41 · 183 阅读 · 0 评论 -
数据结构_队列
My blog 队列 #include <iostream> #include <cstring> #include <string> #include <cmath> #include <algorithm> #include <cstdio> #include <cstdlib> #define ll long原创 2018-11-08 13:22:12 · 201 阅读 · 1 评论 -
数据结构_字符串
字符串 堆的动态分配 My blog //堆 动态分配 //realloc函数用于修改一个原先已经分配的内存块的大小,可以使一块内存的扩大或缩小。 //void *realloc (void *ptr, size_t new_size ); #include <iostream> #include <cstring> #include <algorithm> ...原创 2018-11-08 13:24:05 · 476 阅读 · 1 评论 -
数据结构_数组
数据结构_数组 被窝使人懒惰 ORZ /* &lt;stdarg.h&gt; 利用函数va_start、va_arg和va_end提供遍历未知数目和类型的函数参数表的功能 va_start (va_list ap,x) 初始化ap,使其指向所在函数的参数x之后的第一个参数 va_avg (va_list ap,类型) 返回ap当前指向的参数值,并修改ap,使得ap指向下一个参数("类型",为参数...原创 2018-11-18 19:38:46 · 291 阅读 · 0 评论 -
数据结构_二叉树
ORZ My blog 概念性的东西就没有说的必要了 #include <iostream> #include <cmath> #include <algorithm> #include <cstring> #include <string> #include <queue> #define Status int #defin...原创 2018-11-18 19:45:20 · 200 阅读 · 1 评论 -
KMP模板
学习KMP的话除了看视频之外,推荐一个写的很好的博客。 blog My blog 发现自己没有贴过代码。补一下。 #include&lt;bits/stdc++.h&gt; #define Max 10001 using namespace std; int next[Max]; int Slen,Plen; //下标从0开始 void Get_Next(string p,int next[]...原创 2018-11-18 22:20:29 · 131 阅读 · 0 评论 -
数据结构_图
图图图。的。。基本操作??? 这都是我一个一个敲出来的…… 拒绝伸手党,麻烦复制的时候带上链接 自己的网站,欢迎点击 #include <iostream> #include <cstring> #include <string> #include <algorithm> #include <stack> #include &l...原创 2018-12-09 22:31:42 · 550 阅读 · 2 评论 -
线段树模板
https://www.luogu.org/problemnew/show/P3373 区间查询,区间修改(+,*) 贴个模板(上课去了……)╮(╯▽╰)╭ #include <bits/stdc++.h> #define ll long long #define Max 100002 using namespace std; ll a[Max]; ll p;//取摸的 /*...原创 2019-05-05 16:32:31 · 139 阅读 · 0 评论 -
数据结构_线性表
原文地址 (作者也是我本人) 如果你是为了完成老师的作业,建议不要照抄照搬,自己敲。 线性表的顺序表示和实现 #include <iostream> #include <cstring> #include <string> #include <cstdio> #include <algorithm> #include &l...原创 2018-10-12 20:17:08 · 495 阅读 · 1 评论