Suppose that your USB flash drive has a capacity of G gigabytes. Assume that you have the following ‘n’ files that you want to copy onto the flash drive: F1, F2, F3,…., Fn. The ith file Fi takes gi gigabytes. The problem is that your USB flash drive’s capacity, G, is less than the sum of all the gis and also assumes that each file occupies contiguous memory in the flash drive.
That is, .
S1: Assume that you want to maximize the number of files that you copy onto your USB flash drive. A greedy algorithm that selects files to copy in increasing size order (from smallest to largest) will produce an optimal solution.
S2: Assume that you want to maximize the space utilization of your USB flash drive (that is, you want to use as much of your G gigabytes as possible). A greedy algorithm that selects files to copy in decreasing size order from largest to smallest) will produce an optimal solution.
Which of the following statements are true :
Both S1 and S2 are false
Only is true
Only S2 is true
Both S1 and S2 are true
Boost your performance with adaptive practice tests
Practice every concept in the syllabus
Compare your speed and accuracy with your peers
Download the app and practice on the go