Ch04 Trees课件.pptVIP

  1. 1、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
  2. 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  3. 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
  4. 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
  5. 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们
  6. 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
  7. 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
Ch04 Trees课件

§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 AVL Trees Aug May 0 ?1 Nov 0 0 ?2 ?1 Mar 0 1 1 Aug 0 Apr Apr 0 1 2 2 LL Rotation May 0 ?1 Nov 0 0 ?2 ?1 Aug 0 1 1 ?1 Mar 0 0 Apr 0 In general: A 1 B 0 BR BL AR LL Insertion A 2 B 1 BR BL AR LL Rotation B 0 A AR BL BR 0 §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 §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 Feb 0 ?1 1 ?2 2 RL Rotation July 0 Dec 0 ?1 Aug 0 1 ?2 ?1 Jan 0 1 0 ?1 Feb 0 0 Apr 0 Mar 0 ?1 May 0 ?1 ?2 ?1 1 Nov 0 In general: A 1 B 0 BR AL C 0 CL CR RL Insertion A ?2 B 1 BR AL C ?1 CL CR OR RL Rotation BR AL C 0 A 0 or 1 CL B ?1 or 0 CR OR §4 AVL Trees July 0 Dec 0 ?1 Aug 0 1 ?2 ?1 Jan 0 1 0 ?1 Feb 0 0 Apr 0 Mar 0 ?1 May 0 ?1 ?2 ?1 1 Nov 0 June Oct Sept June 0 ?1 ?1 ?1 2 Nov 0 Dec 0 ?1 Aug 1 ?2 ?1 Feb 0 1 July ?1 Apr 0 Mar 0 May ?1 June 0 Jan 0 Oct 0 ?1 ?2 ?1 ?1 Oct 0 Dec 0 ?1 Aug 1 ?2 ?1 Feb 0 1 July ?1 Apr 0 Mar 0 Nov 0 June 0 Jan 0 May 0 Sept 0 ?1 ?1 ?1 ?1 Note: Several bf’s might be changed even if we don’t need to reconstruct the tree. Another option is to keep a height field for each node. §4 AVL Trees /** * Internal method to insert into a subtree. * x is the item to insert. * t is the node that roots the subtree. * Set the new root of the subtree. */ void insert( const Comparable x, AvlNode * t ) { if( t == NULL )

文档评论(0)

l215322 + 关注
实名认证
文档贡献者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档