- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
高度平衡树.ppt
AlgorithmsPresentation 52006/11/28 Presentation 1 : 0940294 郭紹弘 Presentation 1 : 0950300 鄒忠琪 Problem Solving 1 : 0950316 林柏克 Presentation 1 Amortized Analysis of AVL-Trees AVL-tree 高度平衡樹 ( AVL Tree )定義 空的樹為高度平衡樹。 如果 T 是非空二元樹,TL 和 TR 為其左、右子樹 hL 和 hR 分別為 TL 和 TR 的高度 AVL每個子樹高度差必須小於等於1 如 | hL - hR | = 1 。 平衡因子(balance factor) 一個節點 T 的平衡因子 ( balance factor ) BF(T) 的定義為 hL - hR ,BF(T) = 0 , -1 或 1 AVL-tree的旋轉調整 當樹的高度差大於1時,需要重新調整樹高 AVL-tree的旋轉調整 AVL-tree的調整類型 插入A點之前 插入A點之後 Amortized Analysis of AVL-Trees 利用平衡因子bf來分析新增節點過程中,所需要的比較和樹高調整的次數,新增節點可能發生下列情形。 Case 1:樹高沒有增加,不需要改變樹架構來調整平衡 Absorption Case 2:需要改變樹架構來調整平衡 Single Rotation Double Rotation Case 3:樹高增加了,但是不需要作平衡 Height increase AVL-tree 分析參數定義 T0: 一個空的樹 Ti: 在第i個節點插入後,形成的樹 Li: 第i個節點插入後,Critical Path的長度 X1: m個插入次數後,所有節點bf從0改變成-1或是1的次數總和,可表示成下列公式 Val(Ti): 插入i個節點後的樹,還未平衡的節點數 Case 1 : Absorption Case 2.1 single rotation Case 2.2 double rotation Case 3 : Height increase Amortized Analysis of X1 X2: Case 1 : Absorption X3: Case 2.1 single rotation X4: Case 2.2 double rotation X5: Case 3 : Height increase Amortized Analysis of X1 Presentation 2 Amortized Analysis of a Disjoint Set Union Algorithm 0950300 鄒忠琪 Introduction Each is represented by a tree Each node x has a pointer pointing to p(x), its parent in the tree The name of each set is given by a canonical element, namely the root of the associated tree Example Three kinds of operations on disjoint sets Makeset(x) :create a new set containing the single element x Find(x) :return the canonical element of the set containing element x Link( x, y) :form a new set that is the union of the two sets whose canonical elements are x and y. Select and return a canonical element for the new set Example Link(e,x) :make e point to x , and return x Improve This naive algorithm is not very efficient, requiring O(n) time per find operation in the worst case Goal:to keep the trees short Two heuristics to the method Path compression Union by rank P
文档评论(0)