1.A leftist heap with the null path length of the root being r must have at least 2 r + 1 − 1 2^{r+1}-1 2r+1−1 nodes

用递归:假如r成立,则对r+1,右路径r个点,则右子树有 2 r + 1 − 1 2^{r+1}-1 2r+1−1个点。

而左子树Npl至少也为r,则左子树的右路径至少r,则左子树至少 2 r + 1 − 1 2^{r+1}-1 2r+1−1, 2 ( 2 r + 1 − 1 ) + 1 = 2 r + 2 − 1 2(2^{r+1}-1)+1=2^{r+2}-1 2(2r+1−1)+1=2r+2−1

T

2.Merge the two leftist heaps in the following figure. Which one of the following statements is FALSE?

A.the null path length of 6 is the same as that of 2

B.1 is the root with 3 being its right child

C.Along the left most path from top down, we have 1, 2, 4, and 5

D.6 is the left child of 2

C

总是和右子树合并,

小的作为根,左子树照抄

沿着右侧上去检查Npl。Npl是孩子中Npl较小的那个+1

3 Delete the minimum number from the given leftist heap. Which one of the following statements is TRUE?

A.9 is NOT the root

B.24 is the left child of 18

C.18 is the right child of 11

D.13 is the left child of 12

D

4.With the same operations, the resulting skew heap is always more balanced than the leftist heap.

这个是不一定的

F

5.The right path of a skew heap can be arbitrarily long.

T


一直插入类似这种结构(第一个节点不是,是为了方便画)
这样,转过去以后,就会增长左边

左边转过来,就变成右边了

6.Which one of the following statements is FALSE about a skew heap?

A.Skew heaps do not need to maintain the null path length of any node

B.Comparing to leftist heaps, skew heaps are always more efficient in space

C.Skew heaps have O(logN) worst-case cost for merging

D.Skew heaps have O(logN) amortized cost per operation

B是对的,因为不需要存储Npl

C摊销是O(logN),最差应该大于logN

D是对的

7.The amortized time bound of insertions for a skew heap of size N is O(logN).

摊销是logN

T

8.The result of inserting keys 1 to 2^​k−1 for any k>4 in order into an initially empty skew heap is always a full binary tree.

这个很神奇,但是测试一下发现是对的。

9.Merge the two leftist heaps in the following figure. Which one of the following statements is FALSE?

A.2 is the root with 11 being its right child

B.the depths of 9 and 12 are the same

C.21 is the deepest node with 11 being its parent

D.the null path length of 4 is less than that of 2

插入结果如图

D

10.We can perform BuildHeap for leftist heaps by considering each element as a one-node leftist heap, placing all these heaps on a queue, and performing the following step: Until only one heap is on the queue, dequeue two heaps, merge them, and enqueue the result. Which one of the following statements is FALSE?

A.in the k-th run, ⌈N/2​^ k⌉ leftist heaps are formed, each contains 2^​k
​​ nodes

B.the worst case is when N=2^​K for some integer K

C.the time complexity T(N)=O(​N/2​​log2^​0+N/2^2​​log2^​1​​ +​N/2^​3log2^​2​​+⋯+​N/2^Klog2^(K−1)) for some integer K so that N=2^​K
​​
D.the worst case time complexity of this algorithm is Θ(NlogN)

对于D:分治,和归并差不多。T(N)=2T(N/2)+O(logN),复杂度为O(N)

其他没有问题。

11.Insert keys 1 to 15 in order into an initially empty skew heap. Which one of the following statements is FALSE?

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

如果个数满足一个完全二叉树,那么用skew插入是可以插出完全二叉树的。1,2,4,8.叶子是8个(先别急着一个一个插入)

12.Merge the two skew heaps in the following figure. Which one of the following statements is FALSE?

A.15 is the right child of 8

B.14 is the right child of 6

C.1 is the root

D.9 is the right child of 3

A 应该是left child。插入结果如图, 1还得交换孩子,这个图有问题:

B14应该是left child, 原因是当插入到了一个NULL之后就返回了,不会交换孩子

13. If we merge two heaps represented by complete binary trees, the time complexity is Θ(N) provided that the size of each heap is N

Merge就是建新堆,复杂度是O(N) T

14.A skew heap is a heap data structure implemented as a binary tree. Skew heaps are advantageous because of their ability to merge more quickly than balanced binary heaps. The worst case time complexities for Merge, Insert, and DeleteMin are all O(N), while the amorited time complexities for Merge, Insert, and DeleteMin are all O(logN).

T,均摊复杂度为O(logN),最坏是O(N)

15.The NPL of each node in a heap is supposed to be calculated from top down.

应该从叶子开始算,F

16.Which one of the following may be a leftist heap?

ABCD
必须先是堆才行,也就是说大小顺序不能错,大的在上方,或者小的在上方,不能一会儿大一会儿小。

17.Merge the two given skew heaps. Which one of the following statements is FALSE?

A.3 is the root

B.17 is the right child of 16

C.39 is the right child of 25

D.25 is the left child of 14

C,插入结果如图


插入的时候注意:记录下右侧被插入的节点。只有这些节点需要交换孩子,例如6-14中,只有14的右侧被插入了,因此只有14的孩子需要交换。而6的孩子不需要交换。

[题集]Lecture 4. Leftist Heaps and Skew Heaps相关推荐

  1. 搞来一套大厂内部资料(内含C++面试真题集)

    面试最让人糟心的是什么? 提前准备好的问题发挥不上. 临时想好的回答却支支吾吾说不到重点, 结果那自然是: 网上搜别人的面经,看了也用不上,大家履历到底还是差太多: 搜面试真题,会开放的都是一些无名小 ...

  2. ACM题集以及各种总结大全(转)

    ACM题集以及各种总结大全! 虽然退役了,但是整理一下,供小弟小妹们以后切题方便一些,但由于近来考试太多,顾退役总结延迟一段时间再写!先写一下各种分类和题集,欢迎各位大牛路过指正. 一.ACM入门 关 ...

  3. 严蔚敏版《数据结构 (C语言版)》和《数据结构题集》(一)

    这里用的是严蔚敏版<数据结构 (C语言版)>和<数据结构题集>,深感自己的代码写得又渣又无力,打算把这本书好好琢磨透彻,里面的算法和模板都实现一遍,题目也都做一遍.最终能够做到 ...

  4. C语言易错题集 第四部

    C语言易错题集 第四部 一.位操作相关 二.switch()相关 三.输出相关 四.实数相关 五.指针&a相关 六.指针访问数组元素相关 七.转义字符相关 八.类型提升问题 九.是不是正确的浮 ...

  5. C语言易错题集 第二部

    C语言易错题集后续 一.共用体相关(union) 二.do,while相关 三.char溢出相关 四.printf()相关 五.++相关 六. for语句相关 七.calloc()相关 八.defin ...

  6. 面试必备算法题集之「动态规划」Ⅰ

    题目来源:LeetCode-腾讯-动态规划 题库链接:LeetCode传送门 前言 这份题集来源于 LeetCode-腾讯-动态规划 ,怀着想学习动态规划的心(带着害怕面试被问到的恐惧 )做了第一份D ...

  7. c语言解三元一次方程组_七年级下学期《8.3 一元一次不等式组》2020年高频易错题集...

    一.选择题(共10小题) 二.填空题(共5小题) 三.解答题(共5小题) 七年级下学期<8.5 一元一次不等式组>2020年高频易错题集 参考答案与试题解析 一.选择题(共10小题) [点 ...

  8. vfp体积计算机程序,浙江省计算机2级VFP程序调试真题集.doc

    浙江省计算机2级VFP程序调试真题集 程序填空(改错)题: 在考生文件夹的paper 子文件夹中,已有文件Modify.prg,请自己打开文件,在标记&&之前填写所缺代码.调试.保存, ...

  9. 2029年计算机考试题目,计算机二级题集

    计算机二级题集是一款为用户朋友们打造的学习神器,这款计算机二级题集能够提供大量的历年真题给用户朋友们学习,用户还能够在平台上面模拟考试,喜欢的朋友们快来西西下载体验一下吧! 计算机二级题集的介绍: 本 ...

最新文章

  1. 姚期智云栖大会首日演讲:为什么我说现在是金融科技的“新”黄金时代
  2. promise学习记录
  3. 深入理解 Java G1 垃圾收集器
  4. 编写完html文件怎么输出,怎么编写一个html文件?在线等!!
  5. c++ using 前置声明_每日优鲜前置仓模式的配货优化方案案例介绍
  6. Verilog HDL设计实现m序列+选择器
  7. 这款耳机堪比千元级的AirPods
  8. mysql作为tidb从库配置
  9. BUAA_OO_博客作业3——规格
  10. 【李宏毅2020 ML/DL】P75 Generative Adversarial Network | Conditional GAN
  11. 一张图学会python-一张图学会python
  12. 17. Contoller(2)
  13. weblogic部署静态资源文件html,Tomcat和Weblogic部署纯html文件过程解析
  14. 新高考如何选科?职引教你一招简单又直接的方法
  15. MATLAB图像分割的GUI设计
  16. 为了治好拖延症,我祭出了这个自虐的项目,把我搞的卧槽卧槽的
  17. 和铂医药任命陈颖颖博士为首席财务官;​劲方医药和英矽智能达成合作 | 医药健闻...
  18. git将某远程分支的某次提交合并到另一远程分支
  19. 3dmark压力测试 linux,3DMark压力测试发布:彻底榨干你电脑!
  20. 关于Inter CPU的一些认识

热门文章

  1. cv2.cvtColor(image,cv2.COLOR_RGB2BGR) opencv颜色空间的转换
  2. 机器学习(三):线性模型
  3. 软件工程(考研面试版)
  4. 天文学 python_4个天文学入门Python工具
  5. 80C51单片机指令寻址方式
  6. 集合 01集合的概念
  7. 粒子寻优算法PSO学习笔记
  8. HTML中图片轮播效果
  9. The Thirty-fifth Of Word-Day
  10. java double 出现e_JAVA中double类型运算结果异常的解决