[题解]ADS15 External Sorting

1.Suppose we have the internal memory that can handle 12 numbers at a time, and the following two runs on the tapes:

Run 1: 1, 3, 5, 7, 8, 9, 10, 12

Run 2: 2, 4, 6, 15, 20, 25, 30, 32

Use 2-way merge with 4 input buffers and 2 output buffers for parallel operations. Which of the following three operations are NOT done in parallel?

(3分)

A.1 and 2 are written onto the third tape; 3 and 4 are merged into an output buffer; 6 and 15 are read into an input buffer

B.3 and 4 are written onto the third tape; 5 and 6 are merged into an output buffer; 8 and 9 are read into an input buffer

C.5 and 6 are written onto the third tape; 7 and 8 are merged into an output buffer; 20 and 25 are read into an input buffer

D.7 and 8 are written onto the third tape; 9 and 15 are merged into an output buffer; 10 and 12 are read into an input buffer

工作原理:buffer 一个一个按顺序被写。两个run轮流对buffer进行写。

需要注意的是:如果之前有没有merge完成的,比较复杂,需要等待。

一共4+2个buffer, 内存有12个数,因此每个buffer2个数。六个buffer,后两个是输出的

1.写入buffer1,此时没有merge条件

123456
1,3
2.写入第2个buffer
123456
------
1,32,4
3.写入buffer3 1,2merege,写入output buffer
123456
345, 71,2

4.写入bufferr4 1,2 merge,5写入磁盘,所以写入6

123456
5, 76, 153,4
5.写入buffer1 1,3merge,6写入磁盘
123456
8,97155, 6

6.写入buffer2, 1,3 merge, 5写入磁盘

123456
920, 25157,8

7.写入buffer3, delay, 6写入磁盘

123456
920, 2510,12

8.写入buffer4, 1,3 merge

这题A描述的是3->4, B描述的是4->5,C描述的是5->6, D错在不是9和15 merge, 9和10 merge

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值