问题 问答题

【说明】 某机器上需要处理n个作业.job1,job2,…,jobn,其中:

(1)每个作jobi(1≤i≤n)的编号为i,jobi有一个收益值p[i]和最后期限值d[i]小

(2)机器在一个时刻只能处理一个作业,而且每个作业需要一个单位时间进行处理,一旦作业开始就不可中断,每个作业的最后期限值为单位时间的正整数倍; (

3)job1~jobn的收益值呈非递增顺序排列,即p[1)≥P[2]≥…[n);

(4)如果作业jobi在其期限之内完成,则获得收益9[i];如果在其期限之后完成,则没有收益。

为获得较高的收益,采用贪心策略求解在期限之内完成的作业序列。图4-1是基于贪心策略求解该问题的流程图。

(1)整型数组J[]有n个存储单元,变量k众表示在期限之内完成的作业J[1..k]存储所有能够在期限内完成的作业编号,数组J[1..k]里的作业按其最后期限非递减排序,即 d[J[1]]≤…≤d[J[k]]。

(2)为了便于在数组J中加入作业,增加一个虚拟作业Job0,并令d[0]=0,j[0]=0。

(3)算法大致思想:先将作业.job1的编号1放入J[1],然后,依次对每个作业.jobi(2≤i≤n)进行判定,看其能否插入到数组J中。若能,则将其编号插入到数组J的适当位置,并保证J中作业按其最后期限非递减排列;否则不插入。

jobi能插入数组J的充要条件是:jobi和数组J中已有作业均能在其期限之内完成。

(4)流程图中的主要变量院明如下。 i:循环控制变量,表示作业的编号; k:表示在期限内完成的作业数: r:若.jobi能插入数组J,则其在数组了中的位置为r+1: q:循环控制变量,用于移动数组J中的元素。

假设有6个作业job1,job2,…,job6;

完成作业的收益数组p=(p[1],p[2],p[3],p[4],p[5],p[6])=(90,80,50,30,20,10):

每个作业的处理期限数组d=(d[1],d[2],d[3],d[4],d[5],d[6])=(1,2,1,3,4,3)。

请应用试题中描述的贪心策略算法,给出在期限之内处理的作业编号序列()(按作业处理的顺序给出),得到的总收益为()。

答案

参考答案:

(1)1,2,4,5 或job1、job2、job4、job5及其等价描述形式

(2)220

多项选择题
单项选择题

"This is a really exciting time—a new era is starting," says Peter Bazalgette, the chief creative officer of Endemol, the television company behind "Big Brother" and other popular shows. He is referring to the upsurge of interest in mobile television, a nascent industry at the intersection of telecoms and media which offers new opportunities to device-makers, content producers and mobile- network operators. And he is far from alone in his enthusiasm.

Already, many mobile operators offer a selection of television channels or individual shows, which are " streamed" across their third-generation (3G) networks. In South Korea, television is also sent to mobile phones via satellite and terrestrial broadcast networks, which is far more efficient than sending video across mobile networks; similar broadcasts will begin in Japan in April. In Europe, the Italian arm of 3, a mobile operator, recently acquired Canale 7, a television channel, with a view to launching mobile-TV broadcasts in Italy in the second half of 2006. Similar mobile-TV networks will also be built in Finland and America, and are being tested in many other countries.

Meanwhile, Apple Computer, which launched a video-capable version of its iPod portable music-player in October, is striking deals with television networks to expand the range of shows that can be purchased for viewing on the device, including "Lost", "Desperate Housewives" and "Law & Order". TiVo, maker of the pioneering personal video recorder (PVR), says it plans to enable subscribers to download recorded shows on to iPods and other portable devices for viewing on the move. And mobile TV was one of the big trends at the world’s largest technology fair, the Consumer Electronics Show, which took place in Las Vegas this week.

Despite all this activity, however, the prospects for mobile TV are unclear. For a start, nobody really knows if consumers will pay for it, though surveys suggest they like the idea. Informa, a consultancy, says there will be 125 million mobile-TV users by 2010. But many other mobile technologies inspired high hopes and then failed to live up to expectations. And even if people do want TV on the move, there is further uncertainty in three areas: technology, business models and the content itself.

The word "device" in the first sentence of the third paragraph denotes()

A. a satellite and terrestrial broadcast

B. a video-capable version of Apple iPod portable music-player

C. an individual show which is "streamed" across a 3G network

D. a pioneer personal video recorder