Lab: Coin Change & Bin Packing

Site: DIU Blended Learning Center
Course: Algorithms Design & Analysis Lab (Spring 2022)
Book: Lab: Coin Change & Bin Packing
Printed by: Guest user
Date: Sunday, 24 November 2024, 7:51 PM

Greedy Coin Change Algorithm


while S > 0 do 

      c := value of the largest coin no larger than S; 

      num := S / c; 

      pay out num coins of value c; 

      S := S - num*c;


Bin Packing Algorithm


Step 1: Sort the sections in terms of their sizes in decreasing order. 

Step 2: Set Count to 0 

Step 3: Assign sections to a minibus until the summation of the section sizes are less than or equal to C (the capacity of the minibus). Always choose the largest sized section from the sorted list of sections left. 

Step 4: Set Count to Count + 1 

Step 5: Repeat step 3 and step 4 until 0 sections left. 

Step 6: Return Count


Class Discussion: Week-5 (part 1)



Class Discussion: Week-5 PC-B (part 2)



Class Discussion: Week-5 PC-A (part 2)