1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
guapka [62]
3 years ago
10

1- Design a brute-force algorithm for solving the problem below (provide pseudocode): You have a large container with storage si

ze: W lb. You have many Items (n) where each item weight is: wi. the algorithm you design should find the subset of items with the largest weight not exceeding W (Container storage capacity)
2- Submit a simple program in Java that implements your algorithm with an example test run.
Computers and Technology
1 answer:
sladkih [1.3K]3 years ago
3 0

Answer:

Pseudocode is as follows:

// below is a function that takes two parameters:1. An array of items 2. An integer for weight W

// it returns an array of selected items which satisfy the given condition of sum <= max sum.

function findSubset( array items[], integer W)

{

initialize:

maxSum = 0;

ansArray = [];

// take each "item" from array to create all possible combinations of arrays by comparing with "W" and // "maxSum"

start the loop:

// include item in the ansArray[]

ansArray.push(item);

// remove the item from the items[]

items.pop(item);

ansArray.push(item1);

start the while loop(sum(ansArray[]) <= W):

// exclude the element already included and start including till

if (sum(ansArray[]) > maxSum)

// if true then include item in ansArray[]

ansArray.push(item);

// update the maxSum

maxSum = sum(ansArray[items]);

else

// move to next element

continue;

end the loop;

// again make the item[] same by pushing the popped element

items.push(item);

end the loop;

return the ansArray[]

}

Explanation:

You can find example to implement the algorithm.

You might be interested in
Create a new file that contains a summary of the total consumption for three sectors: "Residential," "Commercial," and "Industri
Lera25 [3.4K]

Answer:idk

Explanation:

8 0
3 years ago
Which of these parts of a computer produces an observable result?
lara31 [8.8K]

Answer:

D

Explanation:

6 0
3 years ago
Read 2 more answers
To adjust the margins on a page, users will navigate to the _____ tab.
sashaice [31]
It should be layout or header
6 0
3 years ago
Read 2 more answers
sometimes people who have been playing gta for a while are annoying, i was playing gta this weekend and was trying to escape, bu
murzikaleks [220]
Yeah I stopped playing cause of people like that, I’m sorry you had to deal w that op :) I hope you have a nice day
3 0
3 years ago
Read 2 more answers
A new company is upgrading a media workstation. The computer will be predominantly used for graphic intensive presentations, sli
Lilit [14]

Answer:

The answer is letter A

Explanation:

High-end video, high-end audio, multicore processor

4 0
3 years ago
Other questions:
  • If a student is looking for the degree symbol (°) and it is not found on the main drop-down of symbols, what should the student
    9·2 answers
  • Once your hard drive is installed what needs to be done to the drive and what do these two tasks do
    12·1 answer
  • A(n) _______ gate provides an output of 1 if either or both inputs are 1.
    10·1 answer
  • Which of the following statements about these signs is true?
    13·1 answer
  • __________bits equal one byte.EightTenSixty-fourThirty-twoSix
    10·1 answer
  • Helpppp plsssss!!!<br><br>thanks.
    7·1 answer
  • I need help with this!!! PLEASE!!! Are headphones, radios, dishwashers, and remote controls considered Computers? Do any of them
    10·2 answers
  • The program 4 should first tell users that this is a word analysis file. For any user-given text file, the program will read, an
    6·1 answer
  • Write a script that will calculate a person’s weight on each planet of the solar system, the sun, and the moon. You should creat
    11·1 answer
  • QBasic commands any 10 with examples
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!