Menu

(Solved) : Given Sequence N Items Item Value Vi Buy Item J Buy Items J 1 J 2 Goal Maximize Sum Values Q30047776 . . .

You are given a sequence of n items such that each itemi has value vi and if you buy item j youcan not buy items j + 1 or j + 2. Your goal is tomaximize the sum of the values of all the items purchased.

Give an O(n) runtime algorithm to find a set of items fittingthese criteria, prove the correctness of your algorithm, andanalyze its runtime.

Part 2 grading:

[10 points] Algorithm: Your algorithm generally has a correctidea and has a runtime of O(n)

[20 points] Correctness Proof: Your algorithm is correct on allinputs, has a runtime of O(n), and your proof of correctness islogically sound and complete

[5 points] Runtime Analysis: Your algorithm has a runtime ofO(n) and you correctly analyzed the runtime of your algorithm

[20 points] Implementation: You correctly implemented youralgorithm in code and the implementation is correct on all inputswith runtime O(n)

Expert Answer


Answer to Given Sequence N Items Item Value Vi Buy Item J Buy Items J 1 J 2 Goal Maximize Sum Values Q30047776 . . .

OR