Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
-
Economics & Finance
Selected Reading
C++ Program to Implement First Fit Decreasing for 1-D Objects and M Bins
Here is a C++ Program to implement First Fit Decreasing for 1-D objects and M bins
Required functions and pseudocode:
Begin function binPack() returns number of bins required. Initialize binC = 0 Initialize an array to store binVal. Place items one by one. function sort() to perform bubble sort in the descending order. End
Example Code
#includeusing namespace std; void binPack(int *a, int s, int n) { int binC = 0; int binVal[n]; for (int i = 0; i = 0) { binVal[j] -= a[i]; break; } } for (int i = 0; i > n; cout > a[i]; cout > s; int *seq = sort(a, n); binPack(seq, s, n); }
Output
Enter the number of items in Set: 7 Enter 7 items:4 6 7 5 3 2 1 Enter the bin size: 5 Number of bins required using first fit decreasing algorithm is: 3
Advertisements
