[理工] [資結] 前後序求中序

看板Grad-ProbAsk作者 (開喜烏龍茶)時間15年前 (2011/01/29 16:51), 編輯推噓0(004)
留言4則, 1人參與, 最新討論串1/2 (看更多)
請問下面這一題(99成大電機)是否有辦法求出唯一解 ? Assume the preorder t raversal of a binary tree is "L, J, B, A, C, G, D, E, K, I, F, H" and the postorder traversal of the same tree is "A, C, B, D, E, G, J F, H, I, K, L". Also, assume that the subtree with J as root is a full binary tree and J is the root of L's left subtree. Hence, K is the root of L's right subtree and I the root of K's right subtree. Will you be able to uniquely define the tree ? If yes, please draw the binary tree. If no, please indicate how many distinct binary trees can be derived. -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 118.233.169.131

02/05 22:33, , 1F
我求出的解有兩種可能,差別在於最後的F.H.I的所在位子
02/05 22:33, 1F

02/05 22:35, , 2F
LJLBGI" "ACDEFH(F.H.I在左子樹,""代表空格)
02/05 22:35, 2F

02/05 22:36, , 3F
LJLBG" "IACDE" "" "FH(F.H.I在右子樹,""代表空格)
02/05 22:36, 3F

02/05 22:36, , 4F
有問題在寄站內信討論吧
02/05 22:36, 4F
文章代碼(AID): #1DGzKKcu (Grad-ProbAsk)
文章代碼(AID): #1DGzKKcu (Grad-ProbAsk)