Header img   

楚虽三户,亡秦必楚



PAT(A) 1135. Is It A Red-Black Tree (30)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1135

1135. Is It A Red-Black Tree (30)


There is a kind of balanced binary search tree named red-black tree in the data structure. It has the following 5 properties:

(1) Every node is either red or black. (2) The root is black. (3) Every leaf (NULL) is black. (4) If

Read More
PAT(A) 1134. Vertex Cover (25)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1134

1134. Vertex Cover (25)


A vertex cover of a graph is a set of vertices such that each edge of the graph is incident to at least one vertex of the set. Now given a graph with several vertex sets, you are supposed to tell if each of them is a vertex cover or not.

Read More
PAT(A) 1133. Splitting A Linked List (25)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1133

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 greater than K. The order of th

Read More
PAT(A) 1132. Cut Integer (20)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1132

1132. Cut Integer (20)


Cutting an integer means to cut a K digits long integer Z into two integers of (K/2) digits long integers A and B. For example, after cutting Z = 167334, we have A = 167 and B = 334. It is interesting to see that Z can be devided by the pr

Read More
PAT(A) 1127. ZigZagging on a Tree (30)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1127

1127. ZigZagging 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 sequences. And it is a simple standard routine to print the numbe

Read More
PAT(A) 1126. Eulerian Path (25)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1126

1126. Eulerian Path (25)


In graph theory, an Eulerian path is a path in a graph which visits every edge exactly once. Similarly, an Eulerian circuit is an Eulerian path which starts and ends on the same vertex. They were first discussed by Leonhard Euler while s

Read More
PAT(A) 1125. Chain the Ropes (25)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1125

1125. Chain the Ropes (25)


Given some segments of rope, you are supposed to chain them into one rope. Each time you may only fold two segments into loops and chain them into one piece, as shown by the figure. The resulting chain will be treated as another segmen

Read More
PAT(A) 1124. Raffle for Weibo Followers (20)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1124

1124. Raffle for Weibo Followers (20)


John got a full mark on PAT. He was so happy that he decided to hold a raffle(抽奖) for his followers on Weibo -- that is, he would select winners from every N followers who forwarded his post, and give away gifts. Now you are

Read More
PAT(A) 1123. Is It a Complete AVL Tree (30)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1123

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 done to restore this pro

Read More
PAT(A) 1122. Hamiltonian Cycle (25)

原题目:

原题链接:https://www.patest.cn/contests/pat-a-practise/1122

1122. Hamiltonian Cycle (25)


The "Hamilton cycle problem" is to find a simple cycle that contains every vertex in a graph. Such a cycle is called a "Hamiltonian cycle".

In this problem, you are supposed to tell if a given cycle is a Hamiltonian cycle. <!--more

Read More