Copyright © 2002 Katrin Becker 1998-2002 Last Modified October 2, 200002:31 PM
Programming Assignment:
Cosequential Processing
(to be done individually)
Design and write a program to calculate & analyse seek times for a merge of K runs using both Fibonacci and Cascade Merge approaches.
Input to the program will be:
N : the order of the merge (# of devices = N+1 - no default)
F : the size of the file in Megabytes (default = 1 Gigabyte)
M: the size of available memory (RAM) (default = 10 Megabytes)
R: the size of a record in bytes (default = 1000 bytes)
K: the # of runs (no default)
Output:
Include intermediate calculations at the end of each phase of the merge and print both the number of seeks and the relative file sizes (either in: 1000's of bytes, relative to one original run, or number of records)
Example of hand calculations:
Phase 1: 4 sets of 3 runs:
: 1/3 of RAM for each = 333,333 Bytes = 333 Records
: 1/3 of each run = 3 seeks/run * 3 runs = 9 seeks
: 4 sets to do = 9 * 4 = 36 seeks [36 SEEKS]
Phase 2: 2 sets of 3 runs (1 run in each set has 3,000 records in it)
: 1/3 RAM = 333 records
: 3 seeks/run * 3 runs = 9 seeks, but last file has 2,000 records left,
so 6 more seeks for it = 15 seeks per set
: 2 sets = 2 * 15 = 30 seeks [30 SEEKS]
Phase 3: 1 set of 3 runs (1 has 1000 rec., 1 has 3000 rec., 1 has 5000 rec.)
: 3 seeks/run * 3 runs = 9 seeks, but 2 runs have at least 2000 records
left, so 6 more seeks for each; 6 * 2 = 12 MORE seeks, but
the last run still has 2000 records left so 6 MORE for it