作者LPH66 ((short)(-15074))
看板Prob_Solve
标题Re: [问题] AVL tree
时间Fri Feb 6 01:04:19 2009
※ 引述《aquariusgirl (学,然後知不足)》之铭言:
: ※ [本文转录自 TransCSI 看板]
: 作者: aquariusgirl (学,然後知不足) 看板: TransCSI
: 标题: [问题] AVL tree
: 时间: Thu Feb 5 23:53:44 2009
: 这些数字要建成AVL tree
: 3 5 1 8 6 2 11 4 10 9 7
: 一开始建成这样
: 5
: / \
: 3 8
: / /
: 1 6
: \
: 2
: 然後因为3那边不平衡了 所以要开始做调整
: 要怎麽调啊...
: 还有请问一下
: AVL tree是唯一的吗?
LR式旋转
3 2
/ / \
1 把2拉上来到顶 => 1 3
\
2 3
/
(其实中间我省了一步先左转到 2 再套LL式右转)
/
1
RL式同理
这里写的还满清楚的:
http://zh.wikipedia.org/w/index.php?title=AVL%E6%A0%91&variant=zh-tw
至於唯一嘛...用不同插入顺序试试看就知道啦
--
'Oh, Harry, dont't you
see?' Hermione breathed. 'If she could have done
one thing to make
absolutely sure that every single person in this school
will read your interview, it was
banning it!'
---'Harry Potter and the order of the phoenix', P513
--
※ 发信站: 批踢踢实业坊(ptt.cc)
◆ From: 122.254.20.82