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
likoan [24]
3 years ago
15

Andy is trying to put together a holiday gift knapsack (with W=8) for Sarah. He has n items to choose from, each with infinitely

many copies (aka. knapsack with repetitions). Item i has weight wi, and value vi. Andy wants to pick some items (possibility with duplicates) so their total weight is exactly W, while minimizing the total value of the items picked. If OPT(w) denotes the minimum total value needed to make a weight of w, for every 0 ≤ w ≤ W, (i) write the recursive formula for finding OPT(w) and (ii) compute the values of OPT(1) . . . OPT(8) for the following three items: (w1 = 1, v1 = 3), (w2 = 3, v2 = 2), (w3 = 4, v3 = 3).
Computers and Technology
1 answer:
Sever21 [200]3 years ago
3 0

Answer:

See explaination

Explanation:

Given 3 items: {w1 = 1, v1 = 3}, {w2 = 3, v2 = 2}, {w3 = 4, v3 = 3}

Hence OPT(1) = 3, OPT(3) = 2, OPT(4) = 3

Recursive formula for OPT(k) to minimize value is

OPT(k) = INFINITE if k <= 0

= min(3 + OPT(k-1), 2 + OPT(k-3), 3 + OPT(k-4))

Let us calculate OPT(1) to OPT(8)

OPT(1) = 3

OPT(2) = min ( 3 + OPT(1), 2 + OPT(-1), 3 + OPT(-2)) = 6

OPT(3) = 2

OPT(4) = 3

OPT(5) = min ( 3 + OPT(4), 2 + OPT(2), 3 + OPT(1)) = min(6, 8, 6) = 6

OPT(6) = min ( 3 + OPT(5), 2 + OPT(3), 3 + OPT(2)) = min(9, 4, 9) = 4

OPT(7) = min ( 3 + OPT(6), 2 + OPT(4), 3 + OPT(3)) = min(7, 5, 5) = 5

OPT(8) = min ( 3 + OPT(7), 2 + OPT(5), 3 + OPT(4)) = min(8, 8, 6) = 6

You might be interested in
Create a trigger that prevents anychange(insert, update, or delete)to the grade attribute of the takesrelation that would change
Dmitriy789 [7]
Omg co ol like chicken is funny sometimes
6 0
3 years ago
Sending the same messages to a large number of users is called​
Firlakuza [10]

Answer:

Can you give me the options

3 0
3 years ago
What's the difference between pseudo code and natural language​
ArbitrLikvidat [17]

Answer: While algorithms are generally written in a natural language or plain English language, pseudocode is written in a format that is similar to the structure of a high-level programming language. Program on the other hand allows us to write a code in a particular programming language.

8 0
2 years ago
Read 2 more answers
When a superclass variable refers to a subclass object and a method is called on that object, the proper implementation is deter
Anni [7]

Answer:

D. Late binding

Explanation:

a. early binding.

b. non-binding.

c. on-time binding.

d. late binding.

The compiler performs a process called binding when an object is assigned to an object variable. The early binding (static binding) refers to compile time binding and late binding (dynamic binding) refers to runtime binding. Another name for late binding is dynamic linkages

It is a computer programming mechanism in which the method being called upon an object or the function being called with arguments is looked up by name at runtime.

When a superclass variable refers to a subclass object and a method is called on that object, the proper implementation is determined at execution time. The process of determining the correct method to call is known as Late Binding.

7 0
3 years ago
Read 2 more answers
You can add chart and axes titles on the chart tools format tab or with the chart elements buttom. true or false
Zepler [3.9K]
True. You can add chart and axes titles on the chart tools format tab or with the chart elements button.
4 0
3 years ago
Other questions:
  • Janeal spends her day looking at the stock and bond markets and evaluating how the portfolios of the businesses she serves will
    5·1 answer
  • How can a CRM system help communicate issues in the supply chain between customers and drones?
    10·1 answer
  • Excel assigns the name ____ to the first excel table created in a workbook.
    10·1 answer
  • Access fundamentally refers to the ability of a subject and a(n) ___________ to interact.
    8·1 answer
  • Which is the best response to receiving a threating text from a classmate
    11·2 answers
  • Tech A says that gasoline vapors are lighter than air, so inspection pits do not have a fire hazard like above ground hoists. Te
    9·1 answer
  • A. Get a value for x from the user.
    13·1 answer
  • Define a method named swapValues that takes an array of four integers as a parameter, swaps array elements at indices 0 and 1, a
    12·1 answer
  • What does the Finder do?
    5·1 answer
  • What do you mean by computer ethics?​
    10·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!