当前位置: 首页 > news >正文

高级数据结构与算法习题(9)

一、判断题

1、Let S be the set of activities in Activity Selection Problem. Then the earliest finish activity am​ must be included in all the maximum-size subset of mutually compatible activities of S.

T                F

解析:F。设S是活动选择问题中的一组活动。那么,S的相互兼容活动必须有一些最大大小的子集,其中包括最早完成的活动a​m。但是并不是最早完成活动am​必须包括在S的所有相互兼容活动的最大规模子集中。

2、Let C be an alphabet in which each character c in C has frequency c.freq. If the size of C is n, the length of the optimal prefix code for any character c is not greater than n−1.

T                F

解析:T。根据哈夫曼树的性质,对于字符集大小为 n 的情况,任何一个字符的最优编码长度不会超过 n-1。这是因为在哈夫曼树中,从根节点到叶子节点的路径长度即为该字符的编码长度,而哈夫曼树的最短路径长度为 1,最长路径长度为 n-1。

二、单选题

Consider the problem of making change for n cents using the fewest number of coins. Assume that each coin's value is an integer.
The coins of the lowest denomination(面额) is the cent.

(I) Suppose that the available coins are quarters (25 cents), dimes (10 cents), nickels (5 cents), and pennies (1 cent). The greedy algorithm always yields an optimal solution.

(II) Suppose that the available coins are in the denominations that are powers of c, that is, the denominations are c^0, c^1, ..., c^k for some integers c>1 and k\geq1. The greedy algorithm always yields an optimal solution.

(III) Given any set of k different coin denominations which includes a penny (1 cent) so that there is a solution for every value of n, greedy algorithm always yields an optimal solution.

Which of the following is correct?

A.Statement (I) is false.

B.Statement (II) is false.

C.Statement (III) is false.

D.All of the three statements are correct.

解析:A。贪心算法有时候算出的结果并不是

http://www.lryc.cn/news/342369.html

相关文章:

  • Linux的vim下制作进度条
  • C++学习笔记2
  • 细数:智能物流装备界的并购案~
  • 微信小程序播放编码为 video/mp4;codecs=vp8 opus 的视频没有声音
  • Linux 指令lsblk 作用,以及查看cpu使用情况和磁盘IO iostat指令详解
  • Mybatis之Sqlsession、Connection和Transaction三者间的关系
  • WRT1900ACS搭建openwrt服务器小记
  • Spring AOP(3)
  • 推荐5个免费的国内平替版GPT
  • 弹性云服务器是什么,为何如此受欢迎
  • Docker部署RabbitMQ与简单使用
  • 2024年黄石市建设优质工程评价认定申报条件、流程及材料合集
  • 偏微分方程算法之混合边界条件下的差分法
  • apollo资料整理
  • 森林消防新利器:高扬程水泵的革新与应用/恒峰智慧科技
  • Microsoft Universal Print 与 SAP 集成教程
  • VBA在Excel中字母、数字的相互转化
  • 【C语言】——联合体与枚举
  • java线上问题排查之内存分析(三)
  • 中电金信:金Gien乐道 | 4月要闻速览,精彩再回顾
  • Java将文件目录转成树结构
  • 硬件工程师必读:10条职业发展黄金法则!
  • Redis是什么? 日常运维 Redis 需要注意什么 ? 怎么降低Redis 内存使用 节省内存?
  • 【Android项目】“追茶到底”项目介绍
  • 机试:进制转换问题
  • 目标检测实战(十五): 使用YOLOv7完成对图像的目标检测任务(从数据准备到训练测试部署的完整流程)
  • github中fasttext库README官文文档翻译
  • WouoUIPagePC端实现
  • W801学习笔记十九:古诗学习应用——下
  • 类加载器ClassLoad-jdk1.8