推 weiyung:推 看課本比較實在@@ 01/11 12:41
※ 引述《ilikesg (SG )》之銘言:
: If the preorder or a binary tree is ABCDEFGHI
: , and the inorder representation is BDCAFHGEI,
: What is the original binary tree?
我不是排版高手 但是我來吧= ="
首先看到preorder的開頭是A => A是root
然後看到inorderA的位置 可以知道左子樹有BDC 右子樹有FHGEI
...以此類推
不會的話我建議還是去看課本比較實在= =...
PS你前一題也應該看課本就好
最後樹像這樣:
A
/ \
/ \
B E
\ / \
C F I
/ \
D G
/
H
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.113.139.83