Data Structures & AlgorithmsVery hardICPC regional · GATE CS

Items of sizes [4, 8, 1, 4, 2, 1] must be packed into bins of capacity 10 with no bin over capacity. What is the minimum number of bins needed?

  1. A. 3
  2. B. 2
  3. C. 4
  4. D. 1

Correct answer: B. 2

Bin packing is NP-hard in general, so the exact answer comes from search over assignments (here six items). First-fit, which places each item in the first bin with room, is a heuristic that can use an extra bin.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic