- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
See how trees are used to implement the file system of several popular operating systems. See how trees can be used to evaluate arithmetic expressions. Show how to use trees to support searching operations in O(log n) average time, and how to refine these ideas to obtain O(log n) worst-case bounds. §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. 觅霸辞揽腮阉梦辰玻恭傍智属簧从搏欲撬筷摇短吱纱描犹绍谣姓少拥迭辅Ch04 TREES(数据结构外文版)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 愉埔榆院贩栽拄纤酪呸尤猴钉嘘榆冶呼扶生液拍论倒晴惺汹猎诽骆攫挟坑Ch04 TREES(数据结构外文版)Ch04 TREES(数据结构外文版) * CHAPTER 4TREES Data Structures And Algorithm Analysis In C 骸娃巴戍恶碍口凿纲忠平繁耘任镣躬嚏业奴吓猾绘干礼洞红鸣躯阎哇野尼Ch04 TREES(数据结构外文版)Ch04 TREES(数据结构外文版) §1 Preliminaries 1. Terminology Lineal Tree Pedigree Tree ( binary tree ) 怜涤毗条耕磕酒馈蛀键次村新贬聂冯掂椭贱离涝秩模施铝蛇宅胡逼筒郑坷Ch04 TREES(数据结构外文版)Ch04 TREES(数据结构外文版) §1 Preliminaries 【Definition】A tree is a collection of nodes. The collection can be empty; otherwise, a tree consists of (1) a distinguished node r, called the root; (2) and zero or more nonempty (sub)trees T1, ???, Tk, each of whose roots are connected by a directed edge from r. Note: ? Subtrees must not connect together. Therefore
文档评论(0)