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 sentence best describes the executive branches of state
melamori03 [73]

Answer:

B... I think...

Explanation:

The executive branch of every state is headed by an elected Governor. Most states have a plural executive, in which several key members of the executive branch are directly elected by the people and serve alongside the governor.

8 0
3 years ago
What is the difference between (IF instructions &amp; WHILE instructions )<br> 0<br> 를 들<br> T<br> !
lara31 [8.8K]

Answer:

While statements determine whether a statement is true or false. If what’s stated is true, then the program runs the statement and returns to the first step. If what’s stated is false, the program exits the while and goes to the next statement. An added step to while statements is turning them into continuous loops. If you don’t change the value so that the condition is never false, the while statement becomes an infinite loop.

If statements are the simplest form of conditional statements, statements that allow us to check conditions and change behavior/output accordingly. The part of the statement following the if is called the condition. If the condition is true, the instruction in the statement runs. If the condition is not true, it does not. The if statements are also compound statements. They have a header (if x) followed by an indented statement (an instruction to be followed is x is true). There is no limit to the number of these indented statements, but there must be at least one.

7 0
3 years ago
Fill in the code in the underlined location to display the mouse point location when the mouse is pressed in the pane. pane.setO
Svet_ta [14]

Answer:

The correct option is  pane.setOnMouseClicked((e) -> System.out.println(e.getX() + ", " + e.getY()));

Explanation:

As the complete question is not provided, the complete question is attached herewith.

In order to handle the underlined location the way is to get the position using the MouseClicked event which will be activated when the mouse is clicked and then the values of X and Y position will be printed.

pane.setOnMouseClicked((e) -> System.out.println(e.getX() + ", " + e.getY()));

The other options are not correct as the handle used in them is not defined for this purpose.

6 0
4 years ago
________ uses shared computing resources instead of having local servers or devices to handle computing applications.
Oksanka [162]

Answer:

cloud computing

Explanation:

3 0
3 years ago
I need help with question 3 I’ll give brainliest
Semmy [17]

Answer:

D) Engineering and Technology

Explanation:

Brent Designs or <em>Engineers </em>the equipment or<em> Technology </em>that is used to keep the plant safe.

7 0
3 years ago
Read 2 more answers
Other questions:
  • Which logic gate produces an output of 1 only if both it’s inputs are 0?
    10·2 answers
  • You run anti-virus software on your computer; however, you are experiencing symptoms that may be caused by a virus. What should
    13·1 answer
  • In 3–5 sentences, describe how technology helps business professionals to be more efficient.
    7·2 answers
  • How does the View tab of the ribbon allow you to look at a document?
    9·1 answer
  • Declare a Scanner reference variable fileInput, and assign it a newly created Scanner object that is associated with a file name
    10·1 answer
  • What is the best data structure to solve the following problem? a) A list needs to be built dynamically. b) Data must be easy to
    11·1 answer
  • Many electronic devices use a(n) ?, which contains all the circuit parts in a miniature form.
    14·2 answers
  • 1) APPLICATION BASED QUESTION:-
    5·1 answer
  • Write a programmer defined function that compares the ASCII sum of two strings. To compute the ASCII sum, you need to compute th
    6·1 answer
  • How are the four characteristics of the db approach related to the four functions of a dbms?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!