Prove that binary trees with the same inorder and preorder traversals are identical?

后端 未结 1 1070
一生所求
一生所求 2021-02-03 10:15

Does anybody know how to prove that if two binary trees have the same inorder and preorder traversals, then they are identical? (perhaps by showing that you can

1条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-03 10:55

    The basic idea is how to reconstruct a binary tree by the given inorder and preorder traversals.

    It's possible to reconstruct only one binary tree from the inorder and preorder traversals.

    See:

    • Nonrecursive algorithms for reconstructing a binary tree from its traversals (paper)
    • reconstructing a tree from its preorder and postorder lists (SO question)

    0 讨论(0)
提交回复
热议问题