自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(134)
  • 收藏
  • 关注

原创 数据结构-AVL树

为什么需要AVL树,以树的结构插入或删除大量随机数据时,有可能会导致树的一边轻一边重, 例如极端情况插入依次123456时,树就与链表无异了,Ologn的查找效率也变成了On;AVL树的特性:左右子树高度差最大为1,为了维持这个特性,在插入和删除操作时就需要旋转;旋转规则:当插入位置为对左儿子的左子树进行插入则左单旋,左儿子的右子树时左双旋, 右儿子则镜像;#inclu

2017-08-20 16:41:12 418

原创 数据结构-哈希表

采用分离链接法处理冲突,即当产生冲突时,将以链表的形式将新元素插入原来的元素之后/*********************************************** > Filename: HashTable.cpp > Author: Pyt > Create: 2017-08-19 10:00:00***********

2017-08-20 11:51:21 221

原创 数据结构-查找二叉树

查找二叉树:始终满足任一节点的左儿子小于该节点,右儿子大于该节点,由于其特性,查找二叉树的中序遍历始终为从小到大;需要注意的是二叉查找树的删除,有2种策略,在删除节点不多时可以采用懒惰删除,即标记该节点删除而非真正的delete,第二种是当删除节点只有一个儿子或则为叶子节点即没有儿子时,可直接删除并将儿子移至该节点,而当删除节点有左右儿子时将其右子树最小的节点移动至该节点,当然这里并非真正

2017-08-20 11:42:53 314

原创 数据结构-二叉堆

二叉堆: 堆是一颗完全二叉树, 即除了底层外都被填满,底层从左到右填入的二叉树,注意不是满二叉树;堆的特性:最大堆,堆顶元素始终为最大值,任一节点的左右儿子则均小于该节点,最小堆则相反堆由于其特性可以以数组实现并且不大量浪费空间;当该节点为位置为i时,其左二子位置为2i, 右儿子为2i+1;root节点应在下标为1的位置;这里实现了最大堆/*********

2017-08-20 11:02:14 310

原创 数据结构-队列

队列:先进先出,以尾插法链表实现,增加一个指针记录链表尾,入队时插入尾部,出队时删除链表头以实现先进先出的特性/*********************************************** > Filename: Queue.cpp > Author: Pyt > Create: 2017-08-19 14:46:15******

2017-08-20 10:49:30 160

原创 数据结构-栈

栈:先进后出关于其应用值得一提的便是后缀表达式/*********************************************** > Filename: Stack.cpp > Author: Pyt > Create: 2017-08-19 13:41:43************************************

2017-08-20 10:42:15 159

原创 数据结构-双向链表

准备把基本数据结构以模板类的形式都敲一遍以准备秋招和PAT考试/*********************************************** > Filename: list.cpp > Author: Pyt > Create: 2017-08-04 09:36:04*******************************

2017-08-20 10:37:09 195

原创 1034. Head of a Gang (30)

One way that the police finds the head of a gang is to check people's phone calls. If there is a phone call between A and B, we say that A and B is related. The weight of a relation is defined to be t

2017-05-19 14:13:57 282

原创 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 less than the node's key.The right

2017-05-13 14:10:09 266

原创 1095. Cars on Campus (30)

Zhejiang University has 6 campuses and a lot of gates. From each gate we can collect the in/out times and the plate numbers of the cars crossing the gate. Now with all the information available, you a

2017-05-11 13:57:39 289

原创 1091. Acute Stroke (30)

One important factor to identify acute stroke (急性脑卒中) is the volume of the stroke core. Given the results of image analysis in which the core regions are identified in each MRI slice, your job is to c

2017-05-09 19:38:02 323

原创 1068. Find More Coins (30)

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 coins as payments. However,

2017-05-08 16:13:29 285

原创 1087. All Roads Lead to Rome (30)

Indeed there are many different tourist routes from our city to Rome. You are supposed to find your clients the route with the least cost while gaining the most happiness.Input Specification:E

2017-05-05 18:22:14 457

原创 1018. Public 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 return it to any other stations in the

2017-05-04 18:37:51 295

原创 1076. Forwards on Weibo (30)

Weibo is known as the Chinese version of Twitter. One user on Weibo may have many followers, and may follow many other users as well. Hence a social network is formed with followers relations. When a

2017-05-02 17:20:06 236

原创 1075. PAT Judge (25)

The ranklist of PAT is generated from the status list, which shows the scores of the submittions. This time you are supposed to generate the ranklist for PAT.Input Specification:Each input fil

2017-05-02 16:10:35 282

原创 1072. Gas Station (30)

A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must guarantee that all the hou

2017-04-30 22:11:30 267

原创 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 keys less than the node's key.The righ

2017-04-27 14:06:39 246

原创 1057. Stack (30)

Stack is one of the most fundamental data structures, which is based on the principle of Last In First Out (LIFO). The basic operations include Push (inserting an element onto the top position) and Po

2017-04-27 13:51:08 242

原创 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 the nodes along the path from R

2017-04-27 13:38:34 267

原创 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 pieces and sewing the remaining parts

2017-04-24 14:33:26 304

原创 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 chain can be cut at any position

2017-04-24 13:57:11 197

原创 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 less than the node's key.The right

2017-04-23 16:57:36 285

原创 1042. Shuffling Machine (20)

Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid "inside jobs" where employees collaborate with gambler

2017-04-23 16:48:46 212

原创 1041. Be Unique (20)

Being unique is so important to people on Mars that even their lottery is designed in a unique way. The rule of winning is simple: one bets on a number chosen from [1, 104]. The first one who bets on

2017-04-23 16:45:36 222

原创 1040. Longest Symmetric String (25)

Given a string, you are supposed to output the length of the longest symmetric sub-string. For example, given "Is PAT&TAP symmetric?", the longest symmetric sub-string is "s PAT&TAP s", hence you must

2017-04-23 16:44:26 198

原创 1039. Course List for Student (25)

Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the courses, you are supposed to output the registered course list for each student who comes

2017-04-23 16:41:40 204

原创 1037. Magic Coupon (25)

The magic shop in Mars is offering some magic coupons. Each coupon has an integer N printed on it, meaning that when you use this coupon with a product, you may get N times the value of that product b

2017-04-20 15:01:41 173

原创 1038. Recover the Smallest Number (30)

Given a collection of number segments, you are supposed to recover the smallest number from them. For example, given {32, 321, 3214, 0229, 87}, we can recover many numbers such like 32-321-3214-0229-8

2017-04-20 14:58:18 180

原创 1036. Boys vs Girls (25)

This time you are asked to tell the difference between the lowest grade of all the male students and the highest grade of all the female students.Input Specification: Each input file contains one

2017-04-20 14:50:39 226

原创 1035. Password (20)

To prepare for PAT, the judge sometimes has to generate random passwords for the users. The problem is that there are always some confusing passwords since it is hard to distinguish 1 (one) from l (L

2017-04-20 14:49:05 402

原创 1033. To Fill or Not to Fill (25)

With highways available, driving a car from Hangzhou to any other city is easy. But since the tank capacity of a car is limited, we have to find gas stations on the way from time to time. Different ga

2017-04-20 14:47:07 201

原创 1032. Sharing (25)

11111 22222 967890 i 0000200010 a 1234500003 g -112345 D 6789000002 n 0000322222 B 2345611111 L 0000123456 e 6789000001 o 00010Sample Output 1:67890Sample Input 2:00001 00002 40000

2017-04-20 14:44:45 217

原创 1031. Hello World for U (20)

Given any string of N (>=5) characters, you are asked to form the characters into the shape of U. For example, "helloworld" can be printed as:h de ll rlowoThat is, the characters must be pr

2017-04-20 14:37:41 427

原创 1030. Travel 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 decide the shortest path b

2017-04-19 17:14:10 216

原创 1029. Median (25)

Given an increasing sequence S of N integers, the median is the number at the middle position. For example, the median of S1={11, 12, 13, 14} is 12, and the median of S2={9, 10, 15, 16, 17} is 15. The

2017-04-19 17:10:36 158

原创 1028. List Sorting (25)

Excel can sort records according to any column. Now you are supposed to imitate this function.InputEach input file contains one test case. For each case, the first line contains two integers N

2017-04-19 17:08:26 156

原创 1027. Colors in Mars (20)

People in Mars represent the colors in their computers in a similar way as the Earth people. That is, a color is represented by a 6-digit number, where the first 2 digits are for Red, the middle 2 dig

2017-04-19 17:03:41 153

原创 1025. PAT Ranking (25)

Programming Ability Test (PAT) is organized by the College of Computer Science and Technology of Zhejiang University. Each test is supposed to run simultaneously in several places, and the ranklists w

2017-04-18 17:31:09 209

原创 1024. Palindromic Number (25)

A number that will be the same when it is written forwards or backwards is known as a Palindromic Number. For example, 1234321 is a palindromic number. All single digit numbers are palindromic numbers

2017-04-18 17:29:24 166

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除