在一条笔直公路的一边有许多房子,现要安装消防栓,每个消防栓的覆盖范围远大于房子的面积,如下图所示。现求解能覆盖所有房子的最少消防栓数和安装方案(问题求解过程中,可将房子和消防栓均视为直线上的点)。该问题求解算法的基本思路为:从左端的第一栋房子开始,在其右侧m米处安装一个消防栓,去掉被该消防栓覆盖的所有房子。在剩余的房子中重复上述操作,直到所有房子被覆盖。算法采用的设计策略为( );对应的时间复杂度为(请作答此空)。
假设公路起点A的坐标为0,消防栓的覆盖范围(半径)为20米,10栋房子的坐标为(10,20,,30,35,60,80,160,210,260,300),单位为米。根据上述算法,共需要安装( )个消防栓。以下关于该求解算法的叙述中,正确的是( )。
- A.O(lgn)
- B.O(n)
- C.(nlgn)
- D.O(n2)
正确答案及解析
正确答案
解析
快速排序由C.A.R.Hoare在1962年提出。它的基本思想是:通过一趟排序将要排序的数据分割成独立的两部分,其中一部分的所有数据都比另外一部分的所有数据都要小,然后再按此方法对这两部分数据分别进行快速排序,整个排序过程可以递归进行,以此达到整个数据变成有序序列。快速排序采用的思想是分治思想。贪心算法(又称贪婪算法)是指,在对问题求解时,总是做出在当前看来是最好的选择。也就是说,不从整体最优上加以考虑,他所做出的是在某种意义上的局部最优解。整个算法的时间复杂度是O(nlogn)。场地上可以安排活动1、8、11为一个场地;活动2、6、9一个场地;活动3为一个场地;活动4、7为一个场地;活动5、10为一个场地,共5个场地。
你可能感兴趣的试题
( )is the process of transforming information so it is unintelligible to anyone but the intended recipient.
-
- A.Encryption
- B.Decryption
- C.Security
- D.Protection
- 查看答案
As each application module is completed,it undergoes( )to ensure that it operates correctly and reliably.
-
- A.unit testing
- B.integration testing
- C.system testing
- D.acceptance testing
- 查看答案
( )algorithm specifies the way to arrange data in a particular order.
-
- A.Search
- B.Random
- C.Sorting
- D.Merge
- 查看答案
After analyzing the source code,( )generates machine instructions that will carry out the meaning of the program at a later time.
-
- A.an interpreter
- B.a linker
- C.a compiler
- D.a converter
- 查看答案
( )can help organizations to better understand the information contained within the data and will also help identify the data that is most important to the business and future business decisions.
-
- A.Data processing system
- B.Big Data analytics
- C.Cloud computing
- D.Database management
- 查看答案