-->
当前位置:首页 > 题库 > 正文内容

单选题:Consider the following buffer management problem. Initially the

Luz3年前 (2022-03-02)题库1952
Consider the following buffer management problem. Initially the buffer size (the number of blocks) is one. Each block can accommodate exactly one item. As soon as a new item arrives, check if there is an available block. If yes, put the item into the block, induced a cost of one. Otherwise, the buffer size is doubled, and then the item is able to put into. Moreover, the old items have to be moved into the new buffer so it costs $$k+1$$ to make this insertion, where $$k$$ is the number of old items. Clearly, if there are $$N$$ items, the worst-case cost for one insertion can be $$\Omega (N)$$. To show that the average cost is $$O(1)$$, let us turn to the amortized analysis. To simplify the problem, assume that the buffer is full after all the $$N$$ items are placed. Which of the following potential functions works? @[D](5)

A. The number of items currently in the buffer
B. The opposite number of items currently in the buffer
C. The number of available blocks currently in the buffer
D. The opposite number of available blocks in the buffer



A.The number of items currently in the buffer
B.The opposite number of items currently in the buffer
C.The number of available blocks currently in the buffer
D.The opposite number of available blocks in the buffer


答案:D

发表评论

访客

◎欢迎参与讨论,请在这里发表您的看法和观点。