Data Structures & AlgorithmsModerateICPC regional · Amazon SDE OA

Items of size 6, 5, 4, 3, 2 must be packed into bins of capacity 10 using first-fit decreasing. How many bins are used?

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

Correct answer: C. 2

Sort decreasingly and put each item into the first bin with room. The total size 20 needs at least 2 bins, and first-fit achieves exactly that here.

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

Exams that ask this topic