void Merge(int A[],int p,int q,int r){
int i,j,k;
//计算子数组A[p..q]的元素个数
int n1 = q - p + 1;
//计算子数组A[q+1..r]元素个数
int n2 = r - q;
//创建子数组L,R
int* L = (int*)malloc(sizeof(int)*...
分类:
其他好文 时间:
2014-05-04 12:44:38
阅读次数:
384
这种题一般有二种形式,共同点是都已知中序序列。如果没有中序序列,是无法唯一确定一棵树的。
已知二叉树的前序序列和中序序列,求解树。
1、确定树的根节点。树根是当前树中所有元素在前序遍历中最先出现的元素。
2、求解树的子树。找出根节点在中序遍历中的位置,根左边的所有元素就是左子树,根右边的所有元素就是右子树。若根节点左边或右边为空,则该方向子树为空;若根节点
边和右边都为空,...
分类:
其他好文 时间:
2014-05-03 16:58:36
阅读次数:
325
【题目】
Problem E
Open Credit System
Input: Standard Input
Output: Standard Output
In an open credit system, the students can choose any course they like, but there is a problem. Some of the stude...
分类:
其他好文 时间:
2014-05-03 00:22:50
阅读次数:
380
Excuses, Excuses!
Judge Ito is having a problem with people subpoenaed for jury duty giving rather lame excuses in order to avoid serving. In order to reduce the amount of time requi...
分类:
其他好文 时间:
2014-05-02 23:54:43
阅读次数:
474
【题目】
Your boss has just unearthed a roll of old computer tapes. The tapes have holes in them and might contain some sort of useful information. It falls to you to figure out what is written on them...
分类:
其他好文 时间:
2014-05-02 23:35:16
阅读次数:
526
Where's Waldorf?
Given a m by n grid
of letters, ( ),
and a list of words, find the location in the grid at which the word can be found. A word matches a straight, uninterrupted line o...
分类:
其他好文 时间:
2014-05-02 10:59:15
阅读次数:
514
A regular palindrome is a string of numbers or letters that is the same forward as backward. For example, the string "ABCDEDCBA" is a palindrome because it is the same when the string is read from lef...
分类:
其他好文 时间:
2014-05-02 10:33:09
阅读次数:
332
Problem
A Communist regime is trying to redistribute wealth in a village. They have have decided to sit everyone around a circular table. First, everyone has converted all of their properties to co...
分类:
其他好文 时间:
2014-05-02 10:30:59
阅读次数:
375
There is a war and it doesn't look very promising for your country. Now it's time to act. You have a commando squad at your disposal and planning an ambush on an important enemy camp located nearby. Y...
分类:
其他好文 时间:
2014-05-02 10:28:46
阅读次数:
424
Problem C: The Dragon of Loowater
Once upon a time, in the Kingdom of Loowater, a minor nuisance turned into a major problem.
The shores of Rellau Creek in central Loowater had always been a prime...
分类:
其他好文 时间:
2014-05-02 10:07:09
阅读次数:
402