The multimedia/mobile company you work for is attempting to transfer large media files from older disks to newer ones (on various servers). The task of simply copying over all of these files in any random order is pretty straightforward; however, you believe you can improve upon a haphazard approach and hope to improve the efficiency of storage space on the new disks. You have a collection of m disks, but you believe that if you smartly organize the media files onto the disks, you may not need to use all m disks.
You plan to design a greedy algorithm to transfer media to storage devices efficiently. Note that this is an optimization problem. Optimization problems have a general structure and consist of some quantity to be maximized or minimized under some constraints. In this problem, you have n files (f1, …, fn) with corresponding sizes (in MBs) s1, … sn. You aim to store these files onto m disks, d1, …, dm, with corresponding storage amounts t1, …, tm. Note that one file cannot be spread across multiple disks. In this problem, the goal is to minimize the amount of storage that is not used on each disk (that is used). This should also reduce the total number of disks being used. You would like to fill up each disk as much as possible while leaving a minimally small amount of unused storage. (In the perfect case, each disk would be perfectly filled, and there would be no new storage.) If there are any disks left unused, you will be able to return them for a refund.
Assignment
Part 1
Design a greedy algorithm using pseudocode to solve this optimization problem of transferring files to disk while minimizing unused storage. The inputs to this algorithm are the number of files n, corresponding sizes (in MBs) s1, … sn, m the number of disks, and connected storage amounts t1, …, tm. The algorithm should return an array map[I], which contains the disk index of which the ith media file should be stored.
Comment your pseudocode for increased readability.
Part 2
Discuss the optimality of your algorithm. Is it guaranteed to return an optimal result?
What is the Big-O time complexity of this algorithm in terms of m and n? Justify your answer.
Part 3
What would be the time complexity if you were to solve this problem using a brute force or exhaustive search method? Justify your response.
Answer & Explanation
The multimedia/mobile company you work for is currently attempting to transfer large media files from older disks to newer disks (on various servers). The task of simply copying over... View This Answer