【发布时间】:2015-12-12 19:05:27
【问题描述】:
此信息与树的类型有关。换句话说,你应该认识到这个信息金字塔的峰值(Max Heap),或者二叉搜索树或者两者的组合或者它们都没有。
输入格式如下:
(94,RR) (17,L) (36,RL) (51,R) (20,) (76,RRR) ()
对于给定的对,输入格式树中的每个节点。第一个值表示节点的数量,第二个值表示必须导航才能到达该节点的根路径。 Node 没有办法代表树的根。有了这些信息,您应该能够键入识别树。
例如,树如下:
(94,RR) (17,L) (36,RL) (51,R) (20,) (76,RRR) ()
这棵树不是最大金字塔(max Heap),不是二叉搜索树,也不是它们的组合。
Entrance :
At the entrance you get a string that information is relevant to a tree. Each tree
With the statement (s) end. Entry Exit program ends.
Output:
You are one of the following phrases in your printed output.
1.BST: If the input tree is a binary search tree.
2.MaxHeap: If the tree is the maximum pyramid entrance.
3.BST MaxHeap: If the combined input of binary search tree and the pyramid is the maximum.
4.Nothing: If there is none of the above.
**Sample Input:**
(94,RR) (17,L) (36,RL) (51,R) (20,) (76,RRR) ()
(94,) (59,LL) (61,RR) (53,LR) (79,L) (77,R) (15,RL) ()
(72,) (44,LR) (15,L) (2,LL) ()
Exit
**Sample Output:**
Nothing
MaxHeap
BST
现在我无法为这个问题实现树。请帮助。 谢谢。
【问题讨论】:
-
你的问题是什么?我找不到问题,只是任务。如果是作业,SO 中没有人为你做作业,对不起。
-
为什么没人?我不介意这样做。让我们150美元/小时。交易,@moha6421?
-
好吧,没人免费 :)
-
请原谅我无法解决这个问题的实现树。请帮助。
标签: java c# data-structures tree binary-tree