当前位置:首页计算机类软件水平考试初级程序员->

初级程序员,章节练习,初级程序员案例分析

初级程序员,章节练习,初级程序员案例分析

答案:
本题解析:

(1 )k=0

(2) J<=N

(3) k=k+1或k++ ,或者其他等价形式

(4) d[i]+6 ,或者其他等价形式

(5)0(N)

该题是一个应用型的算法分析题,主要考查考生对贪心算法的理解以及对程序流程图的掌握;做题的关键是对分析清楚题意,并明确流程图中的贪心条件。

该题可转化为求解能覆盖所有房子的基站部署方案的问题,即通过一系列选择求最优解的问题。不难发现,该问题具有最优子结构,并且具有贪心选择性质,可以用贪心法来求解。

贪心法是一种不求最优解,只求满意解的算法。首先初始化, k=0 ;若两房间的距离不超过12公立,则不建基站。否则建基站。算法思想:问题的规模为N。从第一个房子 (最左端)开始部署基站.把第一个基站放置在该房子右方的6公里处,这时,该基站会覆盖从第一个房子到其右方12公里的直线的长度上的所有房子。假设覆盖了N:个房子。此时问题规模编程了N-N1。把第一个基站覆 盖的房子去掉,再从N-N;中选择第一个 (最左端)房子开始布局基站,将第二个基站放置在该房子右方的6公里处。以此类推,直至所有的房子被覆盖。在该算法中包含两个循环,但实际上只是遍历所有房子次,所以算法的时间复杂度为0(N)。

更新时间:2022-10-12 22:25
纠错

你可能感兴趣的试题

单选题

在几种不同类型的软件维护中,通常情况下()所占工作量最大。

  • A.更正性维护
  • B.适应性维护
  • C.完善性维护
  • D.预防性维护
查看答案
单选题

在()中,项目经理的权力是最小的。

  • A.强矩阵型组织
  • B.平衡矩阵组织
  • C.弱矩阵型组织
  • D.项目型组织
查看答案
单选题

在项目实施的过程中,项目经理通过项目周报中的项目进度分析图表发现机房施工进度有延期风险。项目经理立即组织相关人员进行分析,下达了关于改进措施的书面指令。该指令属于( )

  • A.检查措施
  • B.缺陷补救措施
  • C.预防措施
  • D.纠正措施
查看答案
单选题

中级数据库系统工程师,章节精选,中级数据库系统工程师

中级数据库系统工程师,章节精选,中级数据库系统工程师

中级数据库系统工程师,章节精选,中级数据库系统工程师

  • A.见图A
  • B.见图B
  • C.见图C
  • D.见图D
查看答案
单选题

中级数据库系统工程师,章节精选,中级数据库系统工程师

中级数据库系统工程师,章节精选,中级数据库系统工程师

中级数据库系统工程师,章节精选,中级数据库系统工程师

  • A.见图A
  • B.见图B
  • C.见图C
  • D.见图D
查看答案
单选题

中级数据库系统工程师,章节精选,中级数据库系统工程师

中级数据库系统工程师,章节精选,中级数据库系统工程师

  • A.u[1]<v[2]
  • B.u[1]>v[2]
  • C.u[1]<v[5]
  • D.u[1]>v[5]
查看答案
单选题

The IT service manager resigns from a project that meets the scheduleand budget. After hiring an alternativenew manager, the team is opposed to the comments from the new manager. The team is at () developmentstages。

  • A.Forming
  • B.Storming
  • C.Norming
  • D.Performing
查看答案
单选题

()is closet to Deming's definition of Quality。

  • A.Conformance to requirements
  • B.Fitness for use
  • C.Continuousimprovement of products and services
  • D.Customer focus
查看答案
单选题

The IT service manager has learned that a software canimprove the efficiency of current and future project tasks. Because the software is fresh to the Company. Theengineer is not familiar with the software. The lT service manager decides to send the highest level engineero attend the external training course. The proiect manager uses () risk strategies。

  • A.mitigation
  • B.enhancement
  • C.development
  • D.sharing
查看答案
单选题

The process control charts are used ()。

  • A.to graph what typically focuses on the prevention of a problem
  • B.to detect the problem
  • C.to reject the problem
  • D.to determine the acceptability of the sample
查看答案