- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
Ch4.4-5 AVL Tree, Splay Tree
* §4 AVL Trees Target : Speed up searching (with insertion and deletion) Tool : Binary search trees root small large Problem : Although Tp = O( height ), but the height can be as bad as O( N ). CHAPTER 4 Trees 1/18 §4 AVL Trees 〖Example〗 2 binary search trees obtained for the months of the year Nov Oct Sept May Mar June July Dec Aug Apr Feb Jan July June Mar May Oct Sept Nov Jan Feb Aug Apr Dec Entered from Jan to Dec A balanced tree 2/18 Average search time = 3.5 Average search time = 3.1 Average search time of the skew tree = 6.5 §4 AVL Trees Adelson-Velskii-Landis (AVL) Trees (1962) 【Definition】An empty binary tree is height balanced. If T is a nonempty binary tree with TL and TR as its left and right subtrees, then T is height balanced iff (1) TL and TR are height balanced, and (2) | hL ? hR | ? 1 where hL and hR are the heights of TL and TR , respectively. 【Definition】The balance factor BF( node ) = hL ? hR . In an AVL tree, BF( node ) = ?1, 0, or 1. 5 8 2 1 4 3 7 7 8 2 1 4 3 5 4 5 6 3 2 1 7 The height of an empty tree is defined to be –1. 3/18 §4 AVL Trees 〖Example〗 Input the months Mar Mar 0 ?1 May May 0 Nov Nov 0 ?1 ?2 May 0 ?1 Nov 0 0 ?2 ?1 Mar 0 0 0 ? The trouble maker Nov is in the right subtree’s right subtree of the trouble finder Mar. Hence it is called an RR rotation. In general: A ?1 B 0 BL BR AL RR Insertion RR Rotation A ?2 B ?1 BL BR AL BL B 0 A AL BR 0 A is not necessarily the root of the tree Single rotation 4/18 §4 AVL Trees Aug May 0 ?1 Nov 0 0 ?2 ?1 Mar 0 1 1 Aug 0 Apr Apr 0 1 2 2 5/18 Discussion 1: What can we do now? §4 AVL Trees May 0 ?1 Nov 0 0 ?2 ?1 Aug 0 1 1 ?1 Mar 0 0 Apr 0 Jan Jan 0 1 ?1 2 LR Rotation Mar 0 ?1 May 0 ?1 ?2 ?1 Aug 0 1 0 ?1 Jan 0 0 Apr 0 Nov 0 In general: A 1 B 0 BL AR C 0 CR CL LR Insertion A 2 B ?1 BL AR C ?1 CR CL OR LR Rotation BL AR C 0 A ?1 or 0 CR B 0 or 1 CL OR Double Rotation 6/18 §4 AVL Trees Dec July Mar 0 ?1 May 0 ?1 ?2 ?1 Aug 0 1 1 ?1 Jan 0 Apr 0 Nov 0 July 0 Dec 0 Feb
您可能关注的文档
- 2013-2014学年高二英语课件: Unit 3 A healthy life-Reading(新人教版选修6).ppt
- 2013届高三英语一轮复习课件:Module 3 My First Ride on a Tr(外研版必修1.ppt
- 2013人教版八年级英语上册unit3Section A 2a-2d.ppt
- 2013届高考英语一轮复习课件:Unit 3 Under the sea(人教版选修7).ppt
- 2013年高考试题及答案浙江卷英语.doc
- 2013新目标英语八年级上Unit 1 Section B-2.ppt
- 2014·新课标高考总复习·英语Book 2 板块四 Modules 6.ppt
- 2014·新课标高考总复习·英语Book 6 板块十二 Modules 6.ppt
- 2014·新课标高考总复习·英语Book 8 板块十六 Modules 4.ppt
- 2014届执信中学高三第二学期开学考试(英语).doc
- Ch6 Decision Making.ppt
- Changing PracticeChanging Lives.ppt
- Chap.6-图与网络分析.ppt
- Chap002 Baker- advanced accounting.pptx
- Chap007__Futures and Options on Foreign Exchange.ppt
- Chap9 foreign EX market.ppt
- Chapter 10 Designing Greener Processes.ppt
- Chapter 2 Cartoons - Reading (白婷).ppt
- Chapter 5 CPU Scheduling_8266_2079_20110317120209.ppt
- Chapter 7 Lnaguage Variation.ppt
最近下载
- 能源科技有限公司100MW200MWh储能项目110KV升压站安全预评价报告.doc VIP
- 评估公司内部管理制度.doc VIP
- 西师大版五年级上册小学数学期中试卷.pdf VIP
- PEP三年级英语上册 Unit 6单元练习题.doc VIP
- 新解读《EJ_T 287-2000氚内照射剂量估算与评价方法》最新解读.docx VIP
- 统编人教版高中地理必修第一册第一、二章章节单元测试卷(含答案解析).pdf VIP
- 北师大版八年级数学上册 第二章 实数 单元检测试题(有答案).docx VIP
- 风电、光伏项目前期及建设手续办理流程汇编.docx
- 地籍档案管理基本知识 完整版2025.pdf VIP
- 金属非金属矿山安全规程培训.pptx
文档评论(0)