reconstructing a tree from its preorder and postorder lists

前端 未结 7 1879
既然无缘
既然无缘 2020-11-28 04:26

Consider the situation where you have two lists of nodes of which all you know is that one is a representation of a preorder traversal of some tree and the other a represent

7条回答
  •  北海茫月
    2020-11-28 05:09

    Create a binary tree with this restriction that has at least one node that this node has only one child(right or left ,there is no difference).

    Now, write its Preorder and Postorder lists. then try to reconstructing the tree from these lists. and you realize that on that node you cannot decide that its child is right or left.

提交回复
热议问题