Home
SELF STUDY
BrowsePracticeTestsPlaylistDoubts & solutionsFree live classesOther courses

Algorithms

Quick practice

Question 1 of 5

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, \mathrm{G}<\sum_{i-1}^{n} gi.

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 :

A

Both S1 and S2 are false

B

Only \mathrm{S}_{1} is true

C

Only S2 is true

D

Both S1 and S2 are true

Get unlimited practice with GATE - CSIT, DSAI & Interview Preparation subscription

pick

Boost your performance with adaptive practice tests

pick

Practice every concept in the syllabus

pick

Compare your speed and accuracy with your peers

pick

Download the app and practice on the go