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 progra ...
1003 Emergency
As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some ro ...
1076 Forwards on Weibo
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 n ...
1034 Head of a Gang
题外话本题不推荐我的写法,一开始的时候没有做很好的构思,在实际操作过程中修修补补导致代码的可读性非常低。希望二刷的时候可以做进一步的改进。同学推荐晴神《算法笔记》的解题思路,有需要可自行查阅。 One way that the police finds the head of a gang is t ...
1043 Is It a Binary Search Tree
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 ...
1053 Path of Equal Weight
Given a non-empty tree with root R, and with weight W~i~ assigned to each tree node T~i~. The weight of a path from R to L is defined to be the sum of ...
1020 Tree Traversals
Suppose that all the keys in a binary tree are distinct positive integers. Given the postorder and inorder traversal sequences, you are supposed to ou ...
1052 Linked List Sorting
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 ...
1032 Sharing
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 s ...
1060 Are They Equal
If a machine can save only 3 significant digits, the float numbers 12300 and 12358.9 are considered equal since they are both saved as 0.123×105 with ...