Question

C++ The multimedia/mobile company you work for is currently attempting to transfer large media files from...

C++ 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 all of these files in any haphazard order is fairly straightforward; however, you believe that 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 efficiently transfer media to storage devices. 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 list of constraints. In this problem, you have n files (f1, ..., fn) with corresponding sizes (in MBs) s1, ... sn. Your goal is to store these files onto m disks, d1, ..., dm, that have corresponding storages 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 minimize the total number of number of disks being used. That is, 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 unused 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 C++ pseudocode that solves 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 corresponding storages 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 If you were to solve this problem using a brute force or exhaustive search method, what would be the time complexity? Justify your response.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer :

the multimedia/mobile company you work for is currently attempting large media files from older disk to newer disk

part 1 :

   Design a greedy algorithm using pseudocode.

part 2 :

Discuss the optimality of your algorithm.

part 3 :

  if you were to solve this problem using a brute force.

Algorithm:

In greedy algorithm the closet solution that seems to provide optimum solution is chosen.

Thus,first out by heap-sorting.

   the finish in descending order of size

   the disks in descending order of storage amount.

However preserve the original of the files disk

Now you have sorted binary heaps:

files [ ] of size n,and for i=1 to n the size of each files [i] in s[i]

  disks [ ] of size m,and for j = 1 to m the storage amounts of each disk [i] in t[i]

start with the files [1] and disks[1] (i,e.i = 1 to n , j = 1 to m )

if disk[j].capacity <files [i] .size then

next disk to check is disks [j].right

else

map [ index of file [i] = index of disk [j] .reduce the disk storage  amount by the file size,move to the next file

optimality : if we wanted to get an optimal solution ,we did recursively store each possible mapping of file to disk and calculate the optimal solution from the recursion , then implement the optimal solution . that's dynamic programming .however we are being greedy : we want the shortest and quickest checking and while that will be correct, it may not necessarily produce the optimal solution

complexity : O(nlogn + mlogm + nlogm)

we sort each array,then we iterate over all files ,and for each file iterate down a tree of disks :

height of tree is number of nodes (n) so ,log (n).

brute force : here we use only two nested loops. for each file,check every disk so the time complexity is O(nm).

Add a comment
Know the answer?
Add Answer to:
C++ The multimedia/mobile company you work for is currently attempting to transfer large media files from...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT