Re: [理工] [algo] AVL Tree的insert

看板Grad-ProbAsk作者 (Karma Police)時間16年前 (2010/03/20 19:47), 編輯推噓1(102)
留言3則, 1人參與, 最新討論串2/2 (看更多)
※ 引述《fish0112 (魚)》之銘言: : 99交大資結演算 : 第5題組 : 12.What's the pre-order sequence after inserting"2,1,4,5" into an initially : empty AVL tree? : 答案是2,1,4,5 : 13.What's the pre-order sequence after inserting"9,3,6,7" into the above : AVL tree? : 答案是 4,2,1,3,6,5,9,7 : 向版上的高手請教這兩題的詳解,感謝m(__.__)m 12. insert 2 insert 1 insert 4 insert 5 2 2 2 2 / / \ / \ 1 1 4 1 4 \ 5 13. insert 9 RR Rotate insert 3 RL Rotate 2 2 2 4 / \ / \ / \R / \ 1 4 1 5 1 5 => 2 5 \R => / \ L/ \ / \ \ 5 4 9 4 9 1 3 9 \R / 9 3 (注意要從下面的優先) (這裡3很容易放錯) insert 6 RL Rotate insert 7 4 4 4 / \ / \ / \ 2 5 => 2 6 2 6 / \ \R /\ /\ /\ /\ 1 3 9 1 3 5 9 1 3 5 9 done. /L / 6 7 Preorder: 42136597 -- ※ 發信站: 批踢踢實業坊(ptt.cc) ◆ From: 123.204.2.14

03/20 20:50, , 1F
感謝 問一下 insert9 459作RR之後,怎麼得到3加在4左下?
03/20 20:50, 1F

03/20 20:51, , 2F
就是...AVL的insert位置到底怎麼定的呢(._.?)
03/20 20:51, 2F

03/20 20:56, , 3F
知道了,不用回啦:P 感謝原po
03/20 20:56, 3F
文章代碼(AID): #1BfBNZ3h (Grad-ProbAsk)
文章代碼(AID): #1BfBNZ3h (Grad-ProbAsk)