![](https://img-blog.csdnimg.cn/20201014180756927.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
PTA
隨兴
在校研究生,努力奋斗中
展开
-
中国大学生mooc——01-复杂度2 Maximum Subsequence Sum
01-复杂度2Maximum Subsequence Sum(25 分)Given a sequence ofKintegers {N1,N2, ...,NK}. A continuous subsequence is defined to be {Ni,Ni+1, ...,Nj} where1≤i≤j≤K. The Maximum...原创 2019-03-07 20:11:52 · 273 阅读 · 0 评论 -
PAT——1079 Total Sales of Supply Chain (25 分)
1079 Total Sales of Supply Chain (25 分)A supply chain is a network of retailers(零售商), distributors(经销商), and suppliers(供应商)-- everyone involved in moving a product from supplier to customer.Starting...原创 2019-08-31 20:46:56 · 132 阅读 · 0 评论 -
PAT——1103 Integer Factorization (30 分)
1103 Integer Factorization (30 分)The K−P factorization of a positive integer N is to write N as the sum of the P-th power of K positive integers. You are supposed to write a program to find the K−P f...原创 2019-08-31 20:47:32 · 158 阅读 · 0 评论 -
PAT——1130
1130 Infix 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 Specificat...原创 2019-08-31 20:54:01 · 185 阅读 · 0 评论 -
归并排序图文介绍
把数组左边和右边拆成两个小的数组,然后用Merge函数合并:void merge(int arr[], int L, int M, int R){ int LEFT_SIZE = M-L; int RIGHT_SIZE = R - M + 1; int left[LEFT_SIZE]; int right[RIGHT_SIZE]; int i, j, ...原创 2019-09-02 09:55:18 · 219 阅读 · 0 评论 -
堆排序图文介绍
堆的概念:堆是一颗完全二叉树满足父节点 > 子节点(大根堆)完全二叉树:除最后一层外,都是满二叉树,并且最后一层节点是从左到右依次添加。堆化调整:heapify的过程:出现父节点小于子节点时,从中找出最大值,个根节点进行交换。交换后如下:接着找刚刚交换的节点,再对4和5进行交换。整个过程如下:从h-1层开始:2. 对h-1层所有节点进行heapify,使...原创 2019-09-02 09:59:33 · 150 阅读 · 0 评论 -
PAT甲级真题分类
主要考点:树:数的遍历、二叉搜索树图论:最短路径、DFS、BFS排序:快速排序、插入排序、归并排序、堆排序字符串:时间问题其他:多项式问题树树的遍历:1020、1086、1094、1119二叉搜索树:1043、1064图论最短路径:1003、1018、1030BFS: 1094、1127DFS: 1053、1079、1103、1130排序插入排序和归并排序...原创 2019-09-02 10:12:05 · 201 阅读 · 0 评论 -
并查集
理论考虑这样一道题,判断图中是否有环:我们该如何去做呢?利用并查集的方法,过程如下:0->1有边,所以0和1加入一个连通集合中:1->2有边,同样加入到连通集合中。接着检查3->4有边,3和4作为一个集合:1->3有边,把上面两个集合合并,形成0,1,2,3,4集合。(此时已经使用的边有(0,1), (1,2), (3,4), (1,3))此时并...原创 2019-09-05 22:30:37 · 114 阅读 · 0 评论 -
1118 Birds in Forest (25 分)(并查集)
1118 Birds in Forest (25 分)Some scientists took pictures of thousands of birds in a forest. Assume that all the birds appear in the same picture belong to the same tree. You are supposed to help the ...原创 2019-09-05 22:42:23 · 168 阅读 · 0 评论 -
PAT——1053 Path of Equal Weight(30分)(DFS遍历树)
1053 Path of Equal Weight (30 分)Given a non-empty tree with root R, and with weight Wi assigned to each tree node Ti. The weight of a path from R to L is defined to be the sum of the weights of all t...原创 2019-08-31 20:46:02 · 165 阅读 · 0 评论 -
PAT——1127 ZigZagging on a Tree (30 分)(BFS遍历树)
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 s...原创 2019-08-30 20:50:10 · 170 阅读 · 0 评论 -
PAT——1003 Emergency (25 分)
As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the l...原创 2019-08-30 20:01:33 · 104 阅读 · 0 评论 -
PAT——1018 Public Bike Management
1018Public Bike Management(30分)There is a public bike service in Hangzhou City which provides great convenience to the tourists from all over the world. One may rent a bike at any station and ret...原创 2019-08-30 20:13:56 · 112 阅读 · 0 评论 -
PAT——1030 Travel Plan (30 分)
1030Travel Plan(30分)A traveler's map gives the distances between cities along the highways, together with the cost of each highway. Now you are supposed to write a program to help a traveler to d...原创 2019-08-30 20:17:54 · 186 阅读 · 0 评论 -
PAT——1020 Tree Traversals (25 分)(后续+先序构建二叉树)
Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to output the level order traversal sequence of the cor...原创 2019-08-30 20:22:05 · 117 阅读 · 0 评论 -
PAT——1086 Tree Traversals Again (25 分)(先序+中序构建二叉树)
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 ...原创 2019-08-30 20:24:05 · 153 阅读 · 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 t...原创 2019-08-30 20:27:24 · 251 阅读 · 0 评论 -
PAT——1043 Is It a Binary Search Tree (25 分)(插入法构建二叉搜索树)
1043Is It a Binary Search Tree(25分)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...原创 2019-08-30 20:30:50 · 218 阅读 · 0 评论 -
PAT——1064 Complete Binary Search Tree (30 分)(完全二叉搜索树)
1064Complete 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 key...原创 2019-08-30 20:45:16 · 230 阅读 · 0 评论 -
PAT——1094 The Largest Generation (25 分)(BFS遍历树)
1094The Largest Generation(25分)A family hierarchy is usually presented by a pedigree tree where all the nodes on the same level belong to the same generation. Your task is to find the generation ...原创 2019-08-30 20:48:23 · 160 阅读 · 0 评论 -
1107 Social Clusters (30 分)(并查集)
1107 Social Clusters (30 分)When register on a social network, you are always asked to specify your hobbies in order to find some potential friends with the same hobbies. A social cluster is a set of ...原创 2019-09-05 22:42:55 · 154 阅读 · 0 评论