Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
11th Edition
ISBN: 9780134670942
Author: Y. Daniel Liang
Publisher: PEARSON
bartleby

Concept explainers

Question
Book Icon
Chapter 22, Problem 22.27PE
Program Plan Intro

Program for optimal bin packing

Program plan:

  • Import the required package.
  • Create the class “Ex_27”.
  • In the main() function,
    • Create the object to read the number of objects.
    • Read the weight of objects.
    • Execute the for loop until the length of list.
    • Call the method generatePermutation() to generate the permutations possible for the list.
    • Call the method findBest() to find the best container.
    • Execute the for loop to print the containers with respective weight of objects.
  • Define the method findBest(),
    • Return the best bin of the list.
  • Define the method generatePermutation(),
    • Generate the number of permutation possible from the array list.
  • Define the static method firstfit(),
    • Return the item which fits first in the container.
  • Create the class “Bin”,
    • Assign the values of maximum and total weight of bins.
    • Define the method addItem(),
      • Add the weight of item.
    • Define the method getNumberOfObjects(),
      • Return the number of objects.
    • Define the method getTotalWeight(),
      • Return the totalweight.
    • Define the method getMaxWeight(),
      • Return the maximum weight.
    • Define the method toString(),
      • Return the string representation of output.

Blurred answer
Students have asked these similar questions
Prove the following statement:
SUCCESSIVE-OVER-RELAXATION Method TROUBLESHOOTING: Fix the errors in the code below and run the script with your modified code and screenshot your output and codes with answer function [x,numIter,omega] = gaussSeidel(func,x,maxIter,epsilon) % Solves Ax = b by Gauss-Seidel method with relaxation. % USAGE: [x,numIter,omega] = gaussSeidel(func,x,maxIter,epsilon) % INPUT: % func = handle of function that returns improved x using % x = starting solution vector % maxIter = allowable number of iterations (default is 500) % epsilon = error tolerance (default is 1.0e-9) % OUTPUT: % x = solution vector % numIter = number of iterations carried out % omega = computed relaxation factor if nargin < 4; epsilon = 1.0e-9; end if nargin < 3; maxIter = 500; end k = 10; p = 1; omega = 1; for numIter = 1:maxIter xOld = x; x = feval(func,x,omega); dx = sqrt(dot(x - xOld,x - xOld)); if dx < epsilon; return; end if numIter == k; dx1 = dx; end if numIter == k + p omega = 2/(1 + sqrt(1 -…
What is the correct answer in the following?

Chapter 22 Solutions

Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)

Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning