GATE Computer ScienceHardGATE CS (PYQ pattern)

Items 0.5, 0.7, 0.5, 0.2, 0.4, 0.2, 0.5, 0.1, 0.6 (in this order) are packed into bins of capacity 1 by Next-Fit, First-Fit and First-Fit-Decreasing (FFD sorts the items in non-increasing order first). How many bins do they use, as (NF, FF, FFD)?

  1. A. (6, 5, 5)
  2. B. (6, 5, 4)
  3. C. (5, 5, 4)
  4. D. (6, 4, 4)

Correct answer: B. (6, 5, 4)

NF: {0.5}, {0.7}, {0.5, 0.2}, {0.4, 0.2}, {0.5, 0.1}, {0.6} → 6. FF: {0.5, 0.5}, {0.7, 0.2, 0.1}, {0.2, 0.4}, {0.5}, {0.6} → 5. FFD on 0.7, 0.6, 0.5, 0.5, 0.5, 0.4, 0.2, 0.2, 0.1: {0.7, 0.2, 0.1}, {0.6, 0.4}, {0.5, 0.5}, {0.5, 0.2} → 4, which is optimal since the total is 3.7.

More Algorithms questions

Exams that ask this topic