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
Develop a simple food receipt (Python coding)
wlad13 [49]
I am progressing on learning Python, gonna get back to you and complete what you ask as a practice.
7 0
3 years ago
Travis is getting ready to present his PowerPoint slides to his class. What is a good tip Travis should use during his presentat
Margaret [11]

Answer:

REad from slide and speak clearly and slowy.

Explanation:

5 0
3 years ago
When you clear a cell, you are .!?
forsale [732]
Deleting everything. hope it helps
<span />
4 0
3 years ago
Helpppppppppppppppppppppppppppppppppp <br> plxxxxxxxxxxxxxxxxxxx
kobusy [5.1K]
The answer is A.
because online recommendation engine is like consired as an data.
7 0
3 years ago
The figure above shows two pith balls suspended by threads from a support. In the figure, A. the pith balls are uncharged. B. pi
Anna35 [415]
The answer is d I think
3 0
4 years ago
Read 2 more answers
Other questions:
  • true or false manual handling of materials accounts for the primary source of energy in the workplace
    13·2 answers
  • The computers that run the DBMS and all devices that store database data should reside in locked, controlled-access facilities.
    15·1 answer
  • You have a hard disk that is formatted with the fat32 file system. you would like to implement file and folder permissions on th
    10·1 answer
  • Mation about which osi layers of connected cisco devices can be verified with the show cdp neighbors comm
    15·1 answer
  • Emily has to create an audio-visual presentation on animated movies. Which input device will she be LEAST likely to use while cr
    6·1 answer
  • Many people object to increased cybersecurity because _____.
    12·2 answers
  • An indention where the first line of text is indented and the second and succeeding lines start at the left margin is called ___
    8·1 answer
  • Write a recursive function to compute sum of first N integers starting with 1.
    11·1 answer
  • If you are going to develop a special computer, what would it be and explain it's purpose.​
    15·1 answer
  • it is good to know and use the npsd framework while solution envisioning as part of the value discovery cycle. What is NPSD?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!