- 1、本文档共31页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
Pairing Heaps Pairing Heaps Pairing Heaps Experimental results suggest that pairing heaps are actually faster than Fibonacci heaps. Simpler to implement. Smaller runtime overheads. Less space per node. Definition A min (max) pairing heap is a min (max) tree in which operations are done in a specified manner. Node Structure Child Pointer to first node of children list. Left and Right Sibling Used for doubly linked linked list (not circular) of siblings. Left pointer of first node is to parent. x is first node in list iff x.left.child = x. Data Note: No Parent, Degree, or ChildCut fields. Meld – Max Pairing Heap Compare-Link Operation Compare roots. Tree with smaller root becomes leftmost subtree. Insert Create 1-element max tree with new item and meld with existing max pairing heap. Insert Create 1-element max tree with new item and meld with existing max pairing heap. Worst-Case Degree Insert 9, 8, 7, …, 1, in this order. Worst-Case Height Insert 1, 2, 3, …, n, in this order. IncreaseKey(theNode, theAmount) Since nodes do not have parent fields, we cannot easily check whether the key in theNode becomes larger than that in its parent. So, detach theNode from sibling doubly-linked list and meld. IncreaseKey(theNode, theAmount) IncreaseKey(theNode, theAmount) IncreaseKey(theNode, theAmount) Remove Max If empty = fail. Otherwise, remove tree root and meld subtrees into a single max tree. How to meld subtrees? Good way = O(log n) amortized complexity for remove max. Bad way = O(n) amortized complexity. Bad Way To Meld Subtrees currentTree = first subtree. for (each of the remaining trees) currentTree = compareLink(currentTree, nextTree); Example Remove max. Example Actual cost of insert is 1. Actual cost of remove max is degree of root. n/2 inserts (9, 7, 5, 3, 1, 2, 4, 6, 8) followed by n/2 remove maxs. Cost of inserts is n/2. Cost of remove maxs is 1 + 2 + … + n/2 – 1 = Q(n2). If amortized cost of an ins
您可能关注的文档
- 北工商MBA 会计课件 财务报表解读.ppt
- 财政学课件ch8.ppt
- 会计电算化客观题目(有答案).doc
- 河南省唐河县第一高级中学2013-2014学年高一上学期第二次月考英语试题 word版含答案.doc
- 第七章 企业财务报告的设计.ppt
- 第十三章 投资基金2009 04 24.ppt
- 2012第四章复式记账原理.ppt
- 第3章 复式记账.ppt
- 广东省实验中学2009届高三9月月考英语试题.doc
- 2010年上海市金山区中考数学二模卷及答案.doc
- 2023-2024学年湖南省湘西州高一下期末数学试卷附答案解析.docx
- 2023-2024学年四川省凉山州高一下期末数学试卷附答案解析.docx
- 2023-2024学年山东省日照市高一下期末数学试卷附答案解析.docx
- 2023-2024学年河北省张家口市高一下期末数学试卷附答案解析.docx
- 2023-2024学年山东省枣庄市高一下期末数学试卷附答案解析.docx
- 2023-2024学年四川省成都市高一下期末数学试卷附答案解析.docx
- 2023-2024学年四川省成都七中高一下期末数学试卷附答案解析.docx
- 2023-2024学年陕西省咸阳市高一下期末数学试卷附答案解析.docx
- 2023-2024学年山东省泰安市高一下期末数学试卷附答案解析.docx
- 黑龙江省哈尔滨市九中2024-2025年4月考试高二语文试卷.docx
文档评论(0)