推 EntHeEnd:感謝回答 02/07 23:10
※ 引述《EntHeEnd (...)》之銘言:
: ※ 引述《nonagoner (哈)》之銘言:
: : 題目在此
: : http://tinyurl.com/bvoab5
: : 問接續第4題的第5題 不知如何寫起
: : 還有如果對第3題有想法的可以分享一下嗎~
: : 5.continue question 1. If we need to traversal the tree inorder and
: : "each node can only be read once", please write down this inorder
: : traversal pseudo code for this self-defined binary tree.
: : 拜託高手解惑~感恩
: 我想順便請問一下第二題要怎樣有系統的討論...
: 有什麼比較好的切入點嗎 ?
: 像第一個tree
: 可以知道F一定是R E一定是B 不然要rotation
: E是B 表示C做過color change 所以C是 R D是B
: rootA 一定是B B應該是R
(a)符合紅黑樹結構
a
/ \
b [c]
/ \
d e
\
[f]
(b)需rotation改變結構而不符合該圖
a
/ \
b c
\ \
[d] [e]
/
[f]
(c)需rotation改變結構而不符合該圖
a
/ \
b c
\
[d]
\
[e]
我的想法是建不出圖中的樹就not possible
有人有其他正確的做法請多指教
--
※ 發信站: 批踢踢實業坊(ptt.cc)
◆ From: 140.116.141.240