随笔分类 - 数据结构
1
摘要:注:下面的图G都为无向连通图 一、点支配 【支配】 对于图G中顶点集合V中的某一个点A与另一个点B有边链接,叫做点A支配B。 【点支配集】 对于图G中顶点集合V中的某个顶点子集V',可以支配V-V'中的其他点,这个点集V'就是点支配集。 【极小支配集】 对于支配集V,他的任何真子集都不是支配集,就称
阅读全文
摘要:将二叉树线索化,实际上就是将其变为一个循环链表,下面的代码是采用中序的线索化,遍历也是中序遍历,都是基于中序的。在中序遍历序列中求某一结点的前驱和后继的方法:(1)求某一结点的后继:如果所考虑的结点有右孩子,那么就要从该右孩子开始,顺着右孩子的左孩子域找下去,一直到左孩子域为空为止,最后这个结点就是
阅读全文
摘要:1 root是根节点 2 BiNode * temp, * root1; 3 void swap(BiNode root1){ 4 if(root1 == NULL) return; 5 else{ 6 temp = root1->lchild; 7 root1->lchild = root1->rchild; 8 ...
阅读全文
摘要:1、森林转二叉树 (1)、把每棵树转换为二叉树 (2)、第一棵二叉树不动,从第二棵二叉树开始,一次把后一棵二叉树的根结点作为前一棵二叉树的根结点的右孩子,用线连接起来。 转换规则:兄弟相连,长兄为父,孩子靠左。 2、树转二叉树 (1)、加线。在所有的兄弟结点之间加一条线。 (2)、去线。树中的每个结
阅读全文
摘要:原文:https://blog.csdn.net/yanerhao/article/details/45175943 面试题目或多或少会出现这样的选择题或者简答题: 首先我们得知道概念: 前序遍历:先访问当前节点,再访问当前节点的左子树,最后访问当前节点的右子树。对于二叉树,深度遍历与此同。规律:根
阅读全文
摘要:转自大佬博客https://blog.csdn.net/ACdreamers/article/details/16902023 我们首先来看一下什么是前向星. 前向星是一种特殊的边集数组,我们把边集数组中的每一条边按照起点从小到大排序,如果起点相同就按照终点从小到大排序, 并记录下以某个点为起点的所
阅读全文
摘要:大佬博客:https://blog.csdn.net/lee18254290736/article/details/77278769 对于正常的字符串模式匹配,主串长度为m,子串为n,时间复杂度会到达O(m*n),而如果用KMP算法,复杂度将会减少线型时间O(m+n)。设主串为ptr="ababaa
阅读全文
摘要:Description Background Professor Hopper is researching the sexual behavior of a rare species of bugs. He assumes that they feature two different gende
阅读全文
摘要:Write a program that takes as input a rooted tree and a list of pairs of vertices. For each pair (u,v) the program determines the closest common ances
阅读全文
摘要:Farmer John's cows have discovered that the clover growing along the ridge of the hill (which we can think of as a one-dimensional number line) in his
阅读全文
摘要:Astronomers often examine star maps where stars are represented by points on a plane and each star has Cartesian coordinates. Let the level of a star
阅读全文
摘要:1 #include<cstdio> 2 #include<cstring> 3 #include<cmath> 4 #include<iostream> 5 #include<algorithm> 6 using namespace std; 7 const int MAXN=2e5+10; 8
阅读全文
摘要:N个气球排成一排,从左到右依次编号为1,2,3....N.每次给定2个整数a b(a <= b),lele便为骑上他的“小飞鸽"牌电动车从气球a开始到气球b依次给每个气球涂一次颜色。但是N次以后lele已经忘记了第I个气球已经涂过几次颜色了,你能帮他算出每个气球被涂过几次颜色吗? Input每个测试
阅读全文
摘要:In the game of DotA, Pudge’s meat hook is actually the most horrible thing for most of the heroes. The hook is made up of several consecutive metallic
阅读全文
摘要:Your friend Mishka and you attend a calculus lecture. Lecture lasts n minutes. Lecturer tells ai theorems during the i-th minute. Your friend Mishka a
阅读全文
摘要:Description The French author Georges Perec (1936–1982) once wrote a book, La disparition, without the letter 'e'. He was a member of the Oulipo group
阅读全文
摘要:Every year, an elephant qualifies to the Arab Collegiate Programming Competition. He graduated this year, but that’s irrelephant. What’s important is
阅读全文
摘要:Description n children are standing in a circle and playing the counting-out game. Children are numbered clockwise from 1 to n. In the beginning, the
阅读全文
摘要:Problem Description 给一个初始的入栈序列,其次序即为元素的入栈次序,栈顶元素可以随时出栈,每个元素只能入栈依次。输入一个入栈序列,后面依次输入多个序列,请判断这些序列是否为所给入栈序列合法的出栈序列。 例如序列1,2,3,4,5是某栈的压入顺序,序列4,5,3,2,1是该压栈序列
阅读全文
摘要:Problem Description: In computer science, a binary tree is a tree data structure in which each node has at most two children. Consider an infinite ful
阅读全文
1

浙公网安备 33010602011771号