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
[In C language] The concept of a "drunkard's walk" involves an individual who starts walking aimlessly from a lamp post. With each step they take, they move randomly either north, south, east, or west, each with a 25% probability. As the individual takes more steps, they tend to forget where they started and continue taking random steps. The objective is to determine how far the individual will be from the starting point (0,0) after taking N number of steps. To simulate this random walking motion for N steps, we can create a computer program. This program should ask the user to input an integer representing the number of steps to be taken. It should work for any positive value of steps, even for a large number. However, if the user enters an invalid number (such as a negative value), the program should display an error message. After each step, the program should show the current location of the random walker with respect to the origin (lamp post). Finally, when the random…
Need help in python. Problem: 2D random walk. A two dimensional random walk simulates the behavior of a particle moving in a grid of points. At each step, the random walker moves north, south, east, or west with probability 1/4, independently of previous moves. Compose a program that takes a command-line argument n and estimates how long it will take a random walker to hit the boundary of a 2n+1-by-2n+1 square centered at the starting point. //Given codeImport stdioImport randomImport sysn = int(sys.argv[1])//write code herestdio.write('The walker took    ')stdio.write(c)stdio.writeln('    steps')
USE PYTHON LANGUAGE. READ INPUT FROM FILE (NAME THE FILE "input.txt') The problem needs to be solved using Greedy Algorithm Strategy.   Jack and Jill’s parents decide to make their children do some house chores. So they list a set of activities that can be completed in a whole day. In order to complete each activity a certain amount of time (in hours) is required. The parents randomly call each of their children several times separately to choose from the given activities. In each call the children choose an activity based on the following conditions: In each call, each of them chooses one activity Jack has to choose an activity that has not been selected yet. Jill, being very little, should choose an activity that Jack has already chosen so that she can help her older brother because she cannot do such tasks by herself. Jack does not like doing chores, so he decides he would choose the activity that requires the shortest amount of time to complete among the remaining activities.…

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