PAT浙大机试题
文章平均质量分 60
在下宝龙、
这个作者很懒,什么都没留下…
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
1119 Pre- and Post-order Traversals (30 分)根据前序后序来建树再中序输出
1119 Pre- and Post-order Traversals (30 分)不采用柳神的方式来做,柳神的太牛了,平常人看不懂。我就按照正常的建树规则来建树。想要作出这种题,你需要自己先思考,把前序和后序画出来,自己建树构建一下,多加思考映像才能深刻。思路:很显然,前序的第一个值和后序的最后一个值是一样的。设置前序的左边为prel,右边为prer。后序的左边为postl,右边为postr。 那么可以发现前序中prel+1的下标值肯定是左子树的节点,后序的prer-1肯定是右子树的节点。通过原创 2021-06-25 20:09:13 · 299 阅读 · 2 评论 -
1135 Is It A Red-Black Tree 测试点2和3
我先吐为敬!(5) For each node, all simple paths from the node to descendant leaves contain the same number of black nodes.这个性质一定要搜索到NULL 节点再来判断。否则就有可能出现你认为是红黑树,但它不是红黑树如:我比较老实按照算法笔记来建造树:思路就是因为是二叉搜索树,所以可以直接知道中序遍历,根据中序和前序遍历来构建树;构建好树之后DFS一直搜索到NULL节点,然后判断黑色的原创 2021-06-20 23:44:05 · 535 阅读 · 4 评论 -
PAT一些 C++实用的方法
PAT一些 C++实用的方法1、C++方法1、accumulate2、String 和char数组转换 strcpy() c_str()2、sscanf() sprintf()3、atoi() ,atof() ,stoi()函数,to_string()4、lower_bound() upper_bound()5、isalnum() 判断是否为字母数字6、 isdigit() 判断是否为数字7、isalpha()判断是否为字母8、tolower()函数与toupper()函数 大小写字符转换9、transfo原创 2021-06-03 20:33:25 · 480 阅读 · 0 评论 -
PAT 甲 1105 Spiral Matrix (25 分) 螺旋矩阵
PAT 甲 1105 Spiral Matrix (25 分) 螺旋矩阵1105 Spiral Matrix (25 分)This time your job is to fill a sequence of N positive integers into a spiral matrix in non-increasing order. A spiral matrix is filled in from the first element at the upper-left corner, then原创 2021-05-06 22:43:45 · 175 阅读 · 0 评论
分享