摘要: 给定一个插入序列就可以唯一确定一棵二叉搜索树。然而,一棵给定的二叉搜索树却可以由多种不同的插入序列得到。例如分别按照序列{2, 1, 3}和{2, 3, 1}插入初始为空的二叉搜索树,都得到一样的结果。于是对于输入的各种插入序列,你需要判断它们是否能生成一样的二叉搜索树。 输入格式: 输入包含若干组 阅读全文
posted @ 2019-05-28 10:23 Acoccus 阅读(159) 评论(0) 推荐(0) 编辑
摘要: An inorder binary tree traversal can be implemented in a non-recursive way with a stack. For example, suppose that when a 6-node binary tree (with the 阅读全文
posted @ 2019-05-28 10:22 Acoccus 阅读(130) 评论(0) 推荐(0) 编辑
摘要: Given a tree, you are supposed to list all the leaves in the order of top down, and left to right. Input Specification: Each input file contains one t 阅读全文
posted @ 2019-05-28 10:21 Acoccus 阅读(167) 评论(0) 推荐(0) 编辑
摘要: #include #define MaxTree 12 #define ElementType char #define Null -1 #define Tree int struct TreeNode { ElementType element; Tree left; Tree right; }t1[MaxTree], t2[MaxTree]; Tree build... 阅读全文
posted @ 2019-05-28 10:19 Acoccus 阅读(217) 评论(0) 推荐(0) 编辑
摘要: 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 s 阅读全文
posted @ 2019-05-28 10:18 Acoccus 阅读(582) 评论(0) 推荐(0) 编辑
摘要: 1 #include <cstdio> 2 #include <stdlib.h> 3 typedef struct Node* Polynomial; 4 struct Node { 5 int coef; 6 int expon; 7 Polynomial next; 8 }; 9 10 voi 阅读全文
posted @ 2019-05-28 10:16 Acoccus 阅读(339) 评论(0) 推荐(0) 编辑
摘要: 1 #include <cstdio> 2 #define Null -1 3 4 const int maxn = 1e5+2; 5 struct Node { 6 int data; 7 int addr, next; 8 } Lst[maxn]; 9 10 11 12 int input(in 阅读全文
posted @ 2019-05-28 10:16 Acoccus 阅读(245) 评论(0) 推荐(0) 编辑
摘要: Given a sequence of K integers { N​1​​, N​2​​, ..., N​K​​ }. A continuous subsequence is defined to be { N​i​​, N​i+1​​, ..., N​j​​ } where 1. The Max 阅读全文
posted @ 2019-05-28 10:14 Acoccus 阅读(127) 评论(0) 推荐(0) 编辑
摘要: #include const int MAXN = 1e5 + 2; int MaxSubseqSum(int a[], int n) { int ThisSum = 0, MaxSum = 0; for (int i=0; i MaxSum) { MaxSum = ThisSum; } else if (T... 阅读全文
posted @ 2019-05-28 10:13 Acoccus 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 一、题目 Given the relations of all the activities of a project, you are supposed to find the earliest completion time of the project. Input Specification 阅读全文
posted @ 2019-04-28 21:38 Acoccus 阅读(259) 评论(0) 推荐(0) 编辑