Skew Heaps 习题解

本文介绍另一种优化堆合并操作的数据结构。Skew Heaps 是左式堆的简化版,它没有Npl属性,每次合并后无条件交换左右子树。这样虽然不能严格保证合并操作的时间复杂度是O(logN),但摊还代价是O(logN)。本文将进行摊还分析的证明,并给出相关题目的分析。


摊还分析


题目分析

The result of inserting keys 1 to 2k1 for any k>4 in order into an initially empty skew heap is always a full binary tree. (T or F)

过程
首先,我们进行这一插入过程,发现在K=1,2,3,4时都满足假设。
我们通过数学归纳法进行证明。证明的详细过程另开博文介绍。

Insert keys 1 to 15 in order into an initially empty skew heap. Which one of the following statements is FALSE? (3分)
A. the resulting tree is a complete binary tree
B. there are 6 leaf nodes
C. 6 is the left child of 2
D. 11 is the right child of 7

过程

过程和结果如图, 故选B
这里需要注意的一点是,当一棵子树的兄弟是NULL时,他们不需要交换。

发布了24 篇原创文章 · 获赞 12 · 访问量 2万+

猜你喜欢

转载自blog.csdn.net/Woolseyyy/article/details/51586384