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
Which tools allows you to see the edition, version and memory use by windows 10?
cricket20 [7]

Answer:

Resource Monitor

Performance Monitor

Computer Management and Administrative Tools

Advanced User Accounts Tool

Disk Cleanup

Local Group Policy Editor

There is alot do u want them all?

6 0
3 years ago
What type of machine is the energy of a seismic wave recorded?
Sloan [31]
<span>the answer is most likely "Seismograph"</span>
7 0
3 years ago
Which example task should a developer use a trigger rather than a workflow rule for?
Komok [63]

Answer:

A. To set the primary contact on an account record when it is saved

Explanation:

After updating a Contact and then you set the Primary checkbox, the contact becomes the primary contact and this then updates the reference in the Parent Account. Triggers are used for this purpose and not workflow rule. In this case there is only one contact at a time that is set as Primary Contacts, and in the case where an Account does not have any Contacts, the first contact that is created is made the primary and the trigger sets that value in reference.

6 0
3 years ago
Rock, Paper, Scissors is a two-player game in which each player chooses one of three items. If both players choose the same item
mezya [45]

Answer:

The answer is c

Explanation:

7 0
3 years ago
L a s t. i achieve 15 of 15 question on brainly.
Veseljchak [2.6K]
The Control key on a computer keyboard is a key that is used by pressing it in combination with other keys, enabling other keys on the keyboard to perform secondary functions. It is generally labeled as Ctrl.
4 0
2 years ago
Other questions:
  • You notice that somehow you have duplicate records for some of your clients in your database. What should you do?
    13·2 answers
  • What is the code for loading image in matlab
    15·1 answer
  • A forensic investigation discovered that accounts belonging to employees who were terminated numerous years ago were recently us
    9·1 answer
  • I need help answering these questions!
    11·1 answer
  • If a user receives a message whose tone and terminology seems intended to invoke a panic or sense of urgency, it may be a(n) ___
    13·1 answer
  • Need Help!
    9·1 answer
  • For demultiplexing a UDP socket is identified by:_____.
    15·1 answer
  • You can get context-sensitive help information from the Code Editor by_________.A) selecting Contents from the Help menu
    9·1 answer
  • Where can I learn how you hack?​
    8·2 answers
  • PLSSSSS HELPP!! Population biologists are concerned about invasive species such as the zebra mussel found in North American wate
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!