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
Hamish has created a website with an online booking system for his salon appointments. He wants to engage more with his customer
zubka84 [21]

Answer:

  1. Gather customer feedback: Email Survey
  2. Tell customers about the extended opening hours: Social Media Page
  3. Show customers Hamish’s latest hair looks: An online gallery
  4. Help customers find the new salon: A map

Explanation:

1. By sending a questionnaire or survey via email, Hamish can gather customer feedback. Customers can answer these questionnaires directly in attached questions. They can also give feedback over email. Email survery is an economical way to collect feedback and can be sent to a many customers at the same time.

2. Hamish can tell customers about opening hours by a Social Media Page is a mean to assist social media accounts through QR Codes. He can update with his salon information via this web page. When customers scan can see salon's logo, information etc on this page in order to follow.

3. Hamish can display his latest hair looks through an online gallery by sharing his photos to many people. These images are stored, organized  displayed and shared on the website (online gallery). This is a better option than using expensive albums and hard copies.

4. Hamish can help customers to find a new salon by providing a map on his website. This makes easier for customers to locate the new salon as map provides with the navigation information. Customers can get a route  from their current location to the salon.

5 0
3 years ago
Modify a list Modify short_names by deleting the first element and changing the last element to Joe. Sample output with input: '
fredd [130]

Answer:

The modified program is as follows:

user_input = input()

short_names = list(user_input.split(" "))

short_names.pop(0)

short_names[-1] = "Joe"

print(short_names)

Explanation:

This gets the user input

user_input = input()

This converts input to list

short_names = list(user_input.split(" "))

This removes the first item of the list

short_names.pop(0)

This updates the last item to "Joe"

short_names[-1] = "Joe"

This prints the updated list

print(short_names)

3 0
3 years ago
Which of the following is an example of intellectual property?
Gnesinka [82]

Answer:

B. Programming code for a video game

Explanation:

An item is considered an intellectual property if it is intangible in the sense that the actual property cannot be touched and it does not have a physical presence.

Options A, C and D do not fall in this category because they are tangible and they have physical presence.

Only option A, programming source code does not fall into this category.

Hence, <em>B. Programming code for a video game </em> answers the question

8 0
3 years ago
The odometer gauge indicates the ________________.
kkurt [141]
<span>The odometer gauge indicates the total number of miles that a car has been driven, so the correct answer here is a. This is normally a sealed system, so that when a vehicle is sold from one party to another, the mileage driven figure can be trusted.</span>
7 0
4 years ago
Read 2 more answers
I need help
zhuklara [117]

Answer:

do it! you will have to one day so why not now? hopefully she will understand and say nice things as well and be like mom ive

been thinking a lot and i really want to tell you something. Explanation:

8 0
3 years ago
Read 2 more answers
Other questions:
  • After an object has been instantiated, its methods can be accessed using the object's _____, a dot, and a method call
    7·1 answer
  • What is the purpose of requirements gathering
    9·2 answers
  • If you can log into a website to add, edit, or delete content that has been added by you or another user, you are most likely us
    6·1 answer
  • If you want to copy data from one cel to another cell that is several rows down in a worksheet, which method should you use?
    11·1 answer
  • 2.3 Code Practice: Question 3
    14·1 answer
  • What are the different steps while solving a problem using computer? explain​
    7·1 answer
  • Please Help meeeeeeeeeee:
    11·2 answers
  • Why are computer manufacture constantly releases fast computer and do user benefit from ths speed
    9·1 answer
  • Program Convert Measurements:
    15·1 answer
  • How many pages is 1500 words double spaced 12pt font?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!