PAT甲级
文章平均质量分 81
追什么风筝
这个作者很懒,什么都没留下…
展开
-
PAT甲级 1044 Shopping in Mars(二分查找)
1044 Shopping in Mars (25 分)Shopping in Mars is quite a different experience. The Mars people pay by chained diamonds. Each diamond has a value (in Mars dollars M$). When making the payment, the cha...原创 2018-11-13 20:08:21 · 216 阅读 · 0 评论 -
1145 Hashing - Average Search Time (25 分)
1145 Hashing - Average Search Time (25 分)The task of this problem is simple: insert a sequence of distinct positive integers into a hash table first. Then try to find another sequence of integer key...原创 2018-12-07 17:45:44 · 101 阅读 · 0 评论 -
1098 Insertion or Heap Sort (25 分)(插入排序,堆排序)
1098 Insertion or Heap Sort (25 分)According to Wikipedia:Insertion sort iterates, consuming one input element each repetition, and growing a sorted output list. Each iteration, insertion sort remo...原创 2018-12-07 20:45:18 · 657 阅读 · 0 评论 -
1147 Heaps (30 分)
1147 Heaps (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 ...原创 2018-12-07 21:00:31 · 151 阅读 · 0 评论 -
PAT甲级1120Tree Traversals(后序中序建树)
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 ...原创 2018-12-05 21:16:11 · 159 阅读 · 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...原创 2018-12-05 21:23:11 · 213 阅读 · 0 评论 -
1043 Is It a Binary Search Tree (25 分)(判断是不是二叉搜索树)
1043 Is 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...原创 2018-12-05 23:14:51 · 315 阅读 · 0 评论 -
1064 Complete Binary Search Tree (30 分)(完全二叉搜索树)
1064 Complete 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...原创 2018-12-05 23:22:22 · 211 阅读 · 0 评论 -
1110 Complete Binary Tree (25 分)
Given a tree, you are supposed to tell if it is a complete binary tree.Input Specification:Each input file contains one test case. For each case, the first line gives a positive integer N (≤20) wh...原创 2018-12-05 23:28:03 · 391 阅读 · 0 评论 -
1099 Build A Binary Search Tree (30 分)
1099 Build A 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 keys...原创 2018-12-05 23:36:24 · 191 阅读 · 0 评论 -
1078 Hashing (25 分)
1078 Hashing (25 分)The task of this problem is simple: insert a sequence of distinct positive integers into a hash table, and output the positions of the input numbers. The hash function is defined ...原创 2018-12-07 17:32:14 · 185 阅读 · 0 评论 -
PAT甲级1045 Favorite Color Stripe(最长不下降子序列)
1045 Favorite Color Stripe (30 分)Eva is trying to make her own color stripe out of a given one. She would like to keep only her favorite colors in her favorite order by cutting off those unwanted pi...原创 2018-11-13 21:11:20 · 156 阅读 · 0 评论 -
PAT甲级1048 Find Coins (25 分)(二分)
1048 Find Coins (25 分)Eva loves to collect coins from all over the universe, including some other planets like Mars. One day she visited a universal shopping mall which could accept all kinds of coi...原创 2018-11-15 20:02:04 · 308 阅读 · 0 评论 -
pat-1043二叉搜索树
1043 Is 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...原创 2018-11-12 17:20:03 · 126 阅读 · 0 评论 -
PAT甲级-1052 Linked List Sorting (25 分)
1052 Linked List Sorting (25 分)A linked list consists of a series of structures, which are not necessarily adjacent in memory. We assume that each structure contains an integer key and a Nextpointer...原创 2018-11-16 21:40:02 · 118 阅读 · 0 评论 -
PAT甲级-1051 Pop Sequence (stack模拟)
1051 Pop Sequence (25 分)Given a stack which can keep M numbers at most. Push N numbers in the order of 1, 2, 3, ..., N and pop randomly. You are supposed to tell if a given sequence of numbers is a ...原创 2018-11-17 20:25:50 · 149 阅读 · 0 评论 -
PAT甲级-1050 String Subtraction(water)
1050 String Subtraction (20 分)Given two strings S1 and S2, S=S1−S2 is defined to be the remaining string after taking all the characters in S2 from S1. Your task is simply to calcu...原创 2018-11-17 20:37:12 · 119 阅读 · 0 评论 -
PAT甲级-1053 Path of Equal Weight (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 o...原创 2018-11-17 21:05:16 · 160 阅读 · 0 评论 -
堆排序
http://www.cnblogs.com/wanglei5205/p/8733524.html#include<cstdio>#include<iostream>using namespace std;void adjust(int arr[],int len,int index){ int left=2*index+1; int righ...原创 2018-11-29 17:23:41 · 92 阅读 · 0 评论 -
1066 Root of AVL Tree (25 分)
1066 Root of AVL Tree (25 分)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...原创 2018-12-07 16:38:05 · 175 阅读 · 0 评论 -
1123 Is It a Complete AVL Tree (30 分)
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 ...原创 2018-12-06 00:06:46 · 100 阅读 · 0 评论