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
Implement the simulation of a biased 6-sided die which takes the values 1,2,3,4,5,6 with probabilities 1/8,1/12,1/8,1/12,1/12,1/
hjlf

Answer:

see explaination

Explanation:

import numpy as np

import matplotlib.pyplot as plt

a = [1, 2, 3, 4, 5, 6]

prob = [1.0/8.0, 1.0/12.0, 1.0/8.0, 1.0/12.0, 1.0/12.0, 1.0/2.0]

smls = 1000000

rolls = list(np.random.choice(a, smls, p=prob))

counts = [rolls.count(i) for i in a]

prob_exper = [float(counts[i])/1000000.0 for i in range(6)]

print("\nProbabilities from experiment : \n\n", prob_exper, end = "\n\n")

plt.hist(rolls)

plt.title("Histogram with counts")

plt.show()

check attachment output and histogram

4 0
3 years ago
in this third journal assignment, you will think about your work as the product tester for the travel booking software and how y
Temka [501]

My early test cases were greatly aided by the user stories. They gave a thorough summary of what a user can expect from the product as well as data on their past expectations and experiences.

Explanation:

The intricacies of the user's surroundings and the exact technological needs for the product, however, were absent from the user stories.

Greetings, Software Developers!

I'm trying to create more in-depth test cases for my job as a quality test for the online travel software. To do this, I'd like to learn more about the environment of the user and the software's technical requirements. Please give me more details about the technical specs and the user environment.

I'm grateful.

[Name]

To know more about testing
brainly.com/question/22710306
#SPJ4

3 0
1 year ago
What are the five elements of video production
goldenfox [79]
Answer: sight, color, emotion, sound, motion
3 0
3 years ago
Read 2 more answers
What refers to the use of technology to create product styles and designs?
torisob [31]
The answer is graphic design
8 0
3 years ago
In this unit, you learned that test generators can be very helpful when trying to determine if a code runs properly or fails in
sergij07 [2.7K]

Answer:

i dont know you can find the expl below

Explanation:

In this unit, you learned that a test generator can be very helpful when trying to determine if a code runs properly or fails in some situations. For example, let’s say that you were writing a program where the user would input their test grades and the program would tell them their average. What kinds of data would a test generator want to test for that program to be sure that it would work in all situations?

7 0
2 years ago
Other questions:
  • How to you put a color into a cell? <br> a.Shading<br><br> b.Fill<br><br> c.Color<br><br> d.Insert
    8·1 answer
  • What are language standards? At this point in your study of programming, what do they mean to
    5·1 answer
  • The source must decode a message before it can be sent. select one: <br> a. True <br> b. False
    7·1 answer
  • While in slide show mode, if you are not careful you can close the application by clicking the x on the menu bar
    12·2 answers
  • _____ is a systems development technique that produces a graphical representation of a concept or process that systems developer
    11·1 answer
  • Select the correct answer
    11·2 answers
  • Service that connects on-premises software appliances with cloud based storage is ______
    10·1 answer
  • Which of the following questions will most likely be answered by displaying data on a line graph?
    11·1 answer
  • A row in a table _____? for computer class and i’m in the middle of a test!
    14·1 answer
  • ) Printers today have many features that include improved quality, photo printing capabilities, digital camera connectivity, bui
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!