PTA
王重阳道长
这个作者很懒,什么都没留下…
展开
-
1123 Is 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...原创 2019-11-27 16:40:05 · 146 阅读 · 0 评论 -
1119 Pre- 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 ...原创 2019-11-27 15:23:22 · 181 阅读 · 0 评论 -
1032 Sharing (25 分)
To store English words, one method is to use linked lists and store a word letter by letter. To save some space, we may let the words share the same sublist if they share the same suffix. For example,...原创 2019-11-22 21:27:39 · 217 阅读 · 0 评论 -
1028 List Sorting (25 分)
Excel can sort records according to any column. Now you are supposed to imitate this function.Input Specification:Each input file contains one test case. For each case, the first line contains two i...原创 2019-11-22 20:50:29 · 89 阅读 · 0 评论 -
1086 Tree 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 from 1 to 6) is traversed, the stac...原创 2019-11-22 20:20:11 · 107 阅读 · 0 评论 -
1097 Deduplication on a Linked List (25 分)
Given a singly linked list L with integer keys, you are supposed to remove the nodes with duplicated absolute values of the keys. That is, for each value K, only the first node of which the value or a...原创 2019-11-22 19:40:11 · 105 阅读 · 0 评论 -
1133 Splitting A Linked List (25 分)
Given a singly linked list, you are supposed to rearrange its elements so that all the negative values appear before all of the non-negatives, and all the values in [0, K] appear before all those grea...原创 2019-11-22 17:52:55 · 120 阅读 · 0 评论 -
1131 Subway Map (30 分)
In the big cities, the subway systems always look so complex to the visitors. To give you some sense, the following figure shows the map of Beijing subway. Now you are supposed to help people with you...原创 2019-11-22 16:54:05 · 207 阅读 · 0 评论 -
PAT甲级1155 Heap Paths (30 分)
In computer science, a heap is a specialized tree-based data structure that satisfies the heap property: if P is a parent node of C, then the key (the value) of P is either greater than or equal to (i...原创 2019-11-19 19:23:49 · 127 阅读 · 0 评论 -
PAT甲级1130
Given a syntax tree (binary), you are supposed to output the corresponding infix expression, with parentheses reflecting the precedences of the operators.Input Specification:Each input file contains...原创 2019-11-19 19:06:37 · 74 阅读 · 0 评论 -
PAT甲级1138 Postorder Traversal (25 分)
Suppose that all the keys in a binary tree are distinct positive integers. Given the preorder and inorder traversal sequences, you are supposed to output the first number of the postorder traversal se...原创 2019-11-18 21:23:11 · 158 阅读 · 0 评论