Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Suppose that you have a set of n files that have to be copied on 1GB USB drives.

ID: 3826132 • Letter: S

Question

Suppose that you have a set of n files that have to be copied on 1GB USB drives. You can assume that the file sizes are known and always less than or equal to 1GB. The objective is to use the minimum possible number of USB drives. Suppose that you use the following algorithm: if the file fits in the current USB drive, add the file to the drive, otherwise, put this USB drive aside and start a new one. The algorithm is simple in that it does not pre-arrange the files according to their sizes and it never tries to revisit previously closed USB drives to scavenge for additional space.

a. Show an example in which the algorithm uses n/2 drives but the optimum file arrangement uses only n/4+1.

b. Show that the given algorithm is a 2-approximation algorithm

Explanation / Answer

A. Consider 6 files of sizes in MB in following order:

700, 900, 200, 50, 40, 50

·         700mb file goes into USB 1

In total 3 USBs are required to accomdate above 6 files , n=6

So n/2 = 6/2 = 3 usbs.

But if the file arrangement is optimum, less number of usbs are enough. This is explained below:

Arrange files in following order : 700, 200,50, 50 , 900 , 40

Now USB 1 if full

In total 2 USBs were required, which is n/4+1. 6/4 + 1 = 1.5 +1 = 2 (rounded off)

B. The approximation ratio (or approximation factor) of an algorithm is the ratio between the result obtained by the algorithm and the optimal cost or profit. An algorithm with approximation ratio k is called a k-approximation algorithm.

Here normal result of algorithm is n/2 and optimum result is n/4 +1

When we divide normal result with optimum, (n/4 +1)/(n/2), we get 2.5, rounded to 2, proving that above algorithm is 2 approximation algorithm

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote