05 2019 档案

摘要:Source: PAT A1127 ZigZagging on a Tree (30 分) Description: Suppose that all the keys in a binary tree are distinct positive integers. A unique binary 阅读全文
posted @ 2019-05-31 21:59 林東雨 阅读(670) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1129 Recommendation System (25 分) Description: Recommendation system predicts the preference that a user would give to an item. Now you a 阅读全文
posted @ 2019-05-31 21:12 林東雨 阅读(132) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1113 Integer Set Partition (25 分) Description: Given a set of N (>) positive integers, you are supposed to partition them into two disjoi 阅读全文
posted @ 2019-05-29 22:08 林東雨 阅读(196) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1120 Friend Numbers (20 分) Description: Two integers are called "friend numbers" if they share the same sum of their digits, and the sum 阅读全文
posted @ 2019-05-29 21:57 林東雨 阅读(161) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1134 Vertex Cover (25 分) Description: A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at l 阅读全文
posted @ 2019-05-29 21:54 林東雨 阅读(136) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1148 Werewolf - Simple Version (20 分) Description: Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the wer 阅读全文
posted @ 2019-05-28 21:58 林東雨 阅读(162) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1135 Is It A Red-Black Tree (30 分) Description: There is a kind of balanced binary search tree named red-black tree in the data structure 阅读全文
posted @ 2019-05-28 21:25 林東雨 阅读(250) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1137 Final Grading (25 分) Description: For a student taking the online course "Data Structures" on China University MOOC (http://www.icou 阅读全文
posted @ 2019-05-27 18:56 林東雨 阅读(360) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1138 Postorder Traversal (25 分) Description: Suppose that all the keys in a binary tree are distinct positive integers. Given the preorde 阅读全文
posted @ 2019-05-26 23:00 林東雨 阅读(273) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1128 N Queens Puzzle (20 分) Description: The "eight queens puzzle" is the problem of placing eight chess queens on an 8 chessboard so tha 阅读全文
posted @ 2019-05-25 11:17 林東雨 阅读(207) 评论(0) 推荐(0) 编辑
摘要:Date:2019-05-25 11:06:04 回溯法: 如果达到递归边界前的某层,由于事实导致无需任何一个子问题继续递归,便可以直接返回上一层 Description: 8*8的棋盘上任意放置八个皇后棋子,使得任意两个皇后不在同一行,同一列,同一对角线 Code: 阅读全文
posted @ 2019-05-25 11:15 林東雨 阅读(203) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1132 Cut Integer (20 分) Description: Cutting an integer means to cut a K digits lone integer Z into two integers of (K/2) digits long int 阅读全文
posted @ 2019-05-24 21:59 林東雨 阅读(148) 评论(0) 推荐(0) 编辑
摘要:Source: PAT_A1136 A Delayed Palindrome (20 分) Description: Consider a positive integer N written in standard notation with k+1 digits a​i​​ as a​k​​⋯a 阅读全文
posted @ 2019-05-24 21:36 林東雨 阅读(168) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1140 Look-and-say Sequence (20 分) Description: Look-and-say sequence is a sequence of integers as the following: where D is in [0, 9] exc 阅读全文
posted @ 2019-05-24 11:39 林東雨 阅读(233) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1141 PAT Ranking of Institutions (25 分) Description: After each PAT, the PAT Center will announce the ranking of institutions based on th 阅读全文
posted @ 2019-05-24 10:42 林東雨 阅读(249) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1142 Maximal Clique (25 分) Description: A clique is a subset of vertices of an undirected graph such that every two distinct vertices in 阅读全文
posted @ 2019-05-23 23:01 林東雨 阅读(136) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1143 Lowest Common Ancestor (30 分) Description: The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that 阅读全文
posted @ 2019-05-23 20:54 林東雨 阅读(295) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1144 The Missing Number (20 分) Description: Given N integers, you are supposed to find the smallest positive integer that is NOT in the g 阅读全文
posted @ 2019-05-23 20:00 林東雨 阅读(169) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1145 Hashing - Average Search Time (25 分) Description: The task of this problem is simple: insert a sequence of distinct positive integer 阅读全文
posted @ 2019-05-23 19:49 林東雨 阅读(288) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1146 Topological Order (25 分) Description: This is a problem given in the Graduate Entrance Exam in 2018: Which of the following is NOT a 阅读全文
posted @ 2019-05-19 21:32 林東雨 阅读(194) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1147 Heaps (30 分) Description: In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: i 阅读全文
posted @ 2019-05-19 20:40 林東雨 阅读(165) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1076 Forwards on Weibo (30 分) Description: Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, a 阅读全文
posted @ 2019-05-19 20:09 林東雨 阅读(254) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1034 Head of a Gang (30 分) Description: One way that the police finds the head of a gang is to check people's phone calls. If there is a 阅读全文
posted @ 2019-05-18 22:54 林東雨 阅读(207) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1021 Deepest Root (25 分) Description: A graph which is connected and acyclic can be considered a tree. The height of the tree depends on 阅读全文
posted @ 2019-05-18 21:01 林東雨 阅读(165) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1013 Battle Over Cities (25 分) Description: It is vitally important to have all the cities connected by highways in a war. If a city is o 阅读全文
posted @ 2019-05-16 22:00 林東雨 阅读(139) 评论(0) 推荐(0) 编辑
摘要:Date:2019-05-16 21:12:35 图的存储 邻接表: 适合稀疏图,V多E少; 邻接矩阵: 适合稠密图,V少E多; 通常顶点数bu超过1e3时考虑用邻接矩阵,否则会超时; 图的遍历 DFS: BFS: 阅读全文
posted @ 2019-05-16 21:22 林東雨 阅读(533) 评论(0) 推荐(0) 编辑
摘要:Source: PAT 1148 Werewolf - Simple Version (20 分) Description: Werewolf(狼人杀) is a game in which the players are partitioned into two parties: the were 阅读全文
posted @ 2019-05-16 20:52 林東雨 阅读(393) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1149 Dangerous Goods Packaging (25 分) Description: When shipping goods with containers, we have to be careful not to pack some incompatib 阅读全文
posted @ 2019-05-16 20:40 林東雨 阅读(156) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1150 Travelling Salesman Problem (25 分) Description: The "travelling salesman problem" asks the following question: "Given a list of citi 阅读全文
posted @ 2019-05-16 20:29 林東雨 阅读(214) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1151 LCA in a Binary Tree (30 分) Description: The lowest common ancestor (LCA) of two nodes U and V in a tree is the deepest node that ha 阅读全文
posted @ 2019-05-14 21:21 林東雨 阅读(312) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1078 Hashing (25 分) Description: The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, a 阅读全文
posted @ 2019-05-13 21:04 林東雨 阅读(152) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1015 Reversible Primes (20 分) Description: A reversible prime in any number system is a prime whose "reverse" in that number system is al 阅读全文
posted @ 2019-05-12 22:00 林東雨 阅读(119) 评论(0) 推荐(0) 编辑
摘要:素数的判断: 获取素数表: 埃氏筛法(Eratosthenes): 时间复杂度:O( Nlog(logN) ) 第一个测出地球周长的男人-。- 欧氏筛法(Euler): 时间复杂度:O(N) 欧拉待过的俄法德,都曾是世界最强的国家,如果当初欧拉来中国,是不是咱们就年年ACM总冠军了-。- 阅读全文
posted @ 2019-05-12 21:31 林東雨 阅读(406) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1152 Google Recruitment (20 分) Description: In July 2004, Google posted on a giant billboard along Highway 101 in Silicon Valley (shown i 阅读全文
posted @ 2019-05-12 20:42 林東雨 阅读(146) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1153 Decode Registration Card of PAT (25 分) Description: A registration card number of PAT consists of 4 parts: the 1st letter represents 阅读全文
posted @ 2019-05-12 20:01 林東雨 阅读(392) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A 1154 Vertex Coloring (25 分) Description: A proper vertex coloring is a labeling of the graph's vertices with colors such that no two ver 阅读全文
posted @ 2019-05-10 22:51 林東雨 阅读(144) 评论(0) 推荐(0) 编辑
摘要:Date:2019-05-10 20:12:27 直接插入排序 时间复杂度:O(N^2) 空间复杂度:O(1) 稳定性:不会出现相同元素相对位置发生变化 适用性:顺序存储和链式存储 折半插入排序(二分插入排序) 减少了比较元素的次数,约为O(Nlog2N) 由于没有并未减少移动元素的次数,时间复杂度 阅读全文
posted @ 2019-05-10 20:47 林東雨 阅读(203) 评论(0) 推荐(0) 编辑
摘要:Source: PAT_A1098 Insertion or Heap Sort (25 分) Description: According to Wikipedia: Insertion sort iterates, consuming one input element each repetit 阅读全文
posted @ 2019-05-09 22:43 林東雨 阅读(318) 评论(0) 推荐(0) 编辑
摘要:Date:2019-05-08 21:27:07 选择排序: 算法思想:从A[i~n]选择最小的关键字,置于A[i]; 接下来介绍的堆排序属于选择排序的一种; 堆的存储: 采用二叉树的静态存储方式; 结点下标的取值范围【1<= i <= N】; 左孩子下标【i*2】,右孩子下标【i*2+1】; 叶子 阅读全文
posted @ 2019-05-08 21:41 林東雨 阅读(338) 评论(0) 推荐(0) 编辑
摘要:Source: PAT A1155 Heap Paths (30 分) Description: In computer science, a heap is a specialized tree-based data structure that satisfies the heap proper 阅读全文
posted @ 2019-05-07 23:52 林東雨 阅读(344) 评论(0) 推荐(0) 编辑