Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Now, you are given the following items with their corresponding weights and values: item 3. 4 8. 9. weight value 40 6. 12 24 4.

image text in transcribed
image text in transcribed
Now, you are given the following items with their corresponding weights and values: item 3. 4 8. 9. weight value 40 6. 12 24 4. 10 18 23 9. 12 7. 13 Propose a change to the above solution so it runs quicker for this given input. What would be the new performance after applying the proposed change? (a). Briefly describe the changes you want to make (6 pts): (b). After applying the changes you have proposed, what is the performance now, in relation to the original performance (2 pts)? Answer: orivate int DP(int[] weight, int[] val, int capacity)( int[J0 value - new int[val.length+1][capacity+1]; for ( int i = 0; i w ) value[i][w] = value[i-1][w]; else value[i][w] - Math.max(value[i-1][w], val[i-1] + value[i-1][w-weight[1-1]]); return value[val.length][capacity]; Now, you are given the following items with their corresponding weights and values: item 3. 4 8. 9. weight value 40 6. 12 24 4. 10 18 23 9. 12 7. 13 Propose a change to the above solution so it runs quicker for this given input. What would be the new performance after applying the proposed change? (a). Briefly describe the changes you want to make (6 pts): (b). After applying the changes you have proposed, what is the performance now, in relation to the original performance (2 pts)? Answer: orivate int DP(int[] weight, int[] val, int capacity)( int[J0 value - new int[val.length+1][capacity+1]; for ( int i = 0; i w ) value[i][w] = value[i-1][w]; else value[i][w] - Math.max(value[i-1][w], val[i-1] + value[i-1][w-weight[1-1]]); return value[val.length][capacity]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Access Patterns Database Interactions In Object Oriented Applications

Authors: Clifton Nock

1st Edition

0321555627, 978-0321555625

More Books

Students also viewed these Databases questions

Question

1. What are your creative strengths?

Answered: 1 week ago

Question

What metaphors might describe how we work together?

Answered: 1 week ago