造价通

反馈
取消

热门搜词

造价通

取消 发送 反馈意见

树旋转图示

2022/07/16348 作者:佚名
导读:树旋转包括两个不同的方式,分别是右旋转(以P为转轴)和左旋转(以Q为转轴)。两种旋转呈镜像,而且互为逆操作。 下图示意了两种树旋转过程中, 子树的初态和终态: --- --- |Q||P| --- --- /\rightrotation/\ --- --- -------------> --- --- |P||Z||X||Q| --- --- <-------------

树旋转包括两个不同的方式,分别是右旋转(以P为转轴)和左旋转(以Q为转轴)。两种旋转呈镜像,而且互为逆操作。

下图示意了两种树旋转过程中, 子树的初态和终态:

 ---  --- 
|Q||P|
 ---  --- 
/\rightrotation/\
 ---  --- -------------> ---  --- 
|P||Z||X||Q|
 ---  --- <------------- ---  --- 
/\leftrotation/\
 ---  ---  ---  --- 
|X||Y||Y||Z|
 ---  ---  ---  --- 

其中, 右旋转详细步骤如下图 R0, R1, R2 三个步骤所示, 左旋转则如 L0, L1, L2 三个步骤所示。

__
/\
 --- / --- 
|Q|/|Q|
 ---  ---  --- / --- 
 --- |P|/\R1|P|//\ --- 
|Q|R0 --- / --- -----> --- / --- R2|P|
 --- ----->/\/|Z|//|Z|-----> --- 
/\ ---  ---  ---  ---  ---  --- /\
 ---  --- |X||Y||X||Y| ---  --- 
|P||Z| ---  ---  ---  --- |X||Q|
 ---  --- __ ---  --- 
/\/\/\
 ---  --- L2 --- \ --- L0 ---  --- 
|X||Y|<-----|P|\|P|<-----|Y||Z|
 ---  ---  --- \ --- L1 ---  ---  ---  --- 
/\\|Q|<-----/\|Q|
 --- \ ---  --- \ --- 
|X|\\|X|\/\
 ---  ---  ---  ---  ---  --- 
|Y||Z||Y||Z|
 ---  ---  ---  --- 

*文章为作者独立观点,不代表造价通立场,除来源是“造价通”外。
关注微信公众号造价通(zjtcn_Largedata),获取建设行业第一手资讯

热门推荐

相关阅读