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
Write a program that produces the following output (where the user may enter any positive integer under 10):______
Mekhanik [1.2K]

Answer:

// The Scanner class is imported to allow the program receive user input

import java.util.Scanner;

// The class is defined called Solution

public class Solution {

   // The main method is defined which begin program execution

   public static void main(String args[]) {

     // Scanner object 'scan' which receive user input from the keyboard

     Scanner scan = new Scanner(System.in);

     // the userInput variable is initially set to 1 (true) to allow the program continue prompting the user for input

     int userInput = 1;

     // while loop which continue execution as long as the userInput is greater than 0 and less than 10

     while (userInput > 0 && userInput < 10){

         // Prompts is displayed to the user to enter number below 10

         System.out.println("Enter a positive integer under 10:__________");

         // the next input is assigned to userInput

         userInput = scan.nextInt();

     }      

   }

}

Explanation:

The above code continue prompting the user to input an integer as long as the input is greater than 0 and less than 10.

3 0
3 years ago
Illustrate why Sally's slide meets or does not meet professional expectations?
givi [52]

The correct answer to this open question is the following.

Unfortunately, you did not provide any context or background about the situation of Sally and the problem with her slides. We do not know it, just you.

However, trying to be of help, we can comment on the following general terms.

When someone does not meet professional expectations, this means that this individual did not prepare her presentation, lacked technical skills, did not included proper sources, or missed the proper visual aids to make the presentation more attractive and dynamic.

What Sally can improve about her slides is the following.

She can design a better structure for the presentation to have more congruence.

Sally has to clearly establish the goal or goals for her presentation.

She has to add many visuals instead of plain text. This way she can better capture the interest of her audience.

If she can use more vivid colors instead of pale or dark ones, that would be best.

No paragraphs unless necessary. She better uses bullet points.

Take care of the tone of her voice. During her practice, she can record her vice to check how it sounds.

5 0
3 years ago
The role of ICT In government.
Nataly [62]

Answer:

ICT affects the governments by improving responsiveness, increasing efficiency and enhancing governance practices. And by letting them use their own technology.

Explanation:

tell me if it helped ^-^

4 0
1 year ago
What is Microsoft word<br>​
Snowcat [4.5K]

Answer:

A software where you can document letters, essays or anything really.

Explanation:

5 0
3 years ago
Read 2 more answers
What are the WORST computer malware in your opinion it can be worms backdoors and trojans I just want a input, nothing right or
tankabanditka [31]

Answer:

I think probably mydoom

Explanation:

as it estimated 38 billion dollars in damage, also this malware is technically a worm

5 0
2 years ago
Other questions:
  • Andrea needs to format the legend on her chart. She clicks on the chart to select it. Which of the
    13·1 answer
  • I am programming and i want to find the amount of move functions i need to complete the full square. the square is 65 by 70 circ
    8·1 answer
  • Run a Monte Carlo simulation on this vector representing the countries of the 8 runners in this race: runners &lt;- c("Jamaica",
    14·1 answer
  • 5. Question<br> The control flag that isn't really in use by modern networks is the<br> flag.
    15·1 answer
  • Write a program that reads an unspecified number of integers, determines how many positive and negative values have been read, a
    8·1 answer
  • A collection of computers, printers, routers, switches, and other devices
    15·1 answer
  • What is first page of website called​
    10·1 answer
  • Which control program flow options runs to the end of the code block and resumes the break mode at the statement that follows?
    12·1 answer
  • Reading a news release about a product is an example of <br> research.
    9·1 answer
  • Louis has entered a column of expense values. What feature can he use to insert the total expenses at the end of the column?
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!