#include<stdio.h>
      
      void binPacking(int *a, int size, int n) {
        int binCount = 1, i;
        int s = size;
        for (i = 0; i < n; i++) {
          if (s - *(a + i) > 0) {
            s -= *(a + i);
            continue;
          } else {
            binCount++;
            s = size;
            i--;
          }
        }
        printf("Number of bins required: %d", binCount);
      }
      
      C language logo

      Bin Packing

      Codiga's C Recipes

      Bin-Packing algorithm using next fit heuristics

      0 Comments

        Add Comment

        Log in to add a comment

        Codiga - All rights reserved 2022.