如果给你两个遍历序列,你能构造二叉树吗?

If you are given two traversal sequences, can you construct the binary tree?

前序、中序和后序遍历的什么组合生成唯一的二叉树?

以下组合可以唯一标识一棵树。

中单和预购。 中序和后序。 Inorder 和 Level-order.

而下面没有。 后序和预序。 预订和水平订单。 后序和水平序。

更多信息请参考:Geeksforgeek

来自Wikipedia

The trace of a traversal is called a sequentialisation of the tree. The traversal trace is a list of each visited root node. No one sequentialisation according to pre-, in- or post-order describes the underlying tree uniquely. Given a tree with distinct elements, either pre-order or post-order paired with in-order is sufficient to describe the tree uniquely. However, pre-order with post-order leaves some ambiguity in the tree structure.